Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

DATE column should not shows blank with VLOOKUP formula

0

Sir, I have 2 problems in VLOOKUP 

1) In Sheet-1 if Date column cell is blank. After given VLookup formula for result it will show wrong patern like 00-01-1900 [I need it will show blank] 

2) In sheet-2, I have already a formula in cell number C3. After if I want result in D14 with Vlookup then, it will show #N/A.

For detail I have attached file for your kind information. 

Answer
Discuss

Discussion

Naga

I understand that you are new to the Forum but you have inadvertently broken one of the Rule (see link above), specifically rule 5:
Asking Questions
... 5. If you upload a sample file, make sure to clearly state your question in the question itself.

(that way, contributors and other users c=an see if they are interested in your question without opening the file).

In fact your relates to issues with VLOOKUP (so the title should reflect that too).

Please edit your original question to respond to the above points. You'll then get answers hopefully.
John_Ru (rep: 6142) Sep 1, '21 at 6:44 am
Add to Discussion

Answers

0
Selected Answer

Naga

On Sheet1, VLOOKUP returns a blank value if there's no date. When that is converted to a dd-mm-yy date by the TEXT function it seems to convert the blank to 0 which, in Excel date numbering, is equivalent to one less than the start of that numbering scheme, 01 January 1990 (value 1) . That is then displayed as 00-01-90 following your dd-mm-yy formatting.

To prevent that, I suggest you ignore the TEXT function and instead set the formatting of your cells to dd-mm-yy (or "dd/mm/yy") and use an IF function and ISBLANK to check if the VLOOKUP returns a blank (and if so show the null string "") or if not, show the non-blank result of the VLOOKUP:

=IF(ISBLANK(VLOOKUP(D1,A4:C6,3,FALSE)),"",VLOOKUP(D1,A4:C6,3,FALSE))
I've done that in the revised file attached,.

On your sheet 2 and your VLOOKUP on short number, your range should NOT include the headings in row 3 but the main issue is that your column C has a formula:

=Right(B3,3)
 which produces a string. Cell F1 however has General formatting so if you enter 456 say, Excel assumes it is an number and VLOOKUP can't find it since it's comparing a number with a string (even though there's a string 456 which looks the same to us!). It then displays an error code #N/A.

There are two easy solutions however. Either format the search cell F1 as Text  (then entering 456 will produce a string which can be found in column C) or leave F1 with General formatting and convert the cells in column C to numbers by wrapping the Value function around the existing formula, e.g. for C3.: 

=VALUE(RIGHT(B3,3))
In the revised file attached, I've used the latter method.

Hope this helps

Discuss

Discussion

THANKS John...
Naga (rep: 10) Sep 1, '21 at 12:27 pm
Sir, how to BOLD the some words in sentence through this vlookup formula ?
Naga (rep: 10) Sep 2, '21 at 3:00 am
Naga

1) This should be a separate question but the answer is easy...

2) I believe it isn't possible to embolden parts of the cell containing a formula.

Might you use more than one cell to deliver bold (formatted) and non-bold bits?  E.g. LEFT / LEN of the VLOOKUP in one cell then RIGHT for the bold  portion in a second cell. You could make it look like one cell using borders.

Note that Excel's VBA programming language could be used to search /set the cell text directly (replacing the VLOOKUP by code) and to embolden parts of it but that really is a separate question and I suspect beyond your skill level
John_Ru (rep: 6142) Sep 2, '21 at 4:04 am
Add to Discussion
0

Please check the file.

Discuss


Answer the Question

You must create an account to use the forum. Create an Account or Login