Format

konew1

Well-known Member
Joined
Oct 17, 2007
Messages
2,288
Hi. I am doing a vlookup. The target cell that the vlookup refers to could contain text, could be a number representing a year (eg "2011"), could be a complete date number (say 40626 representing 24 March 2011), or could be blank.
I want to format the cell with the vlookup formula so that the result is presented meaningfully. If the format is general then when the result is a full date the presentation is visually meaningless 40626. If I format as a date then when the dta is year only (2011) it returns April 1905. I tried wrapping the vlookup inside year() but that gives errors if the target contains text.

I don't intend to use the vlookup result in any further calculations so don't mind if numeric data is converted to text
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Yep, inconsistent source data is a %#%# !

You're gonna have to do the vlookup twice to test, and wrap the result in a text function...
And set a threshold for the maximum year that might be entered as Year Only (say 3000)

Try

=TEXT(vlookup(...),IF(vlookup(...)>3000,"mm/dd/yyyy","####"))


And of coarse, as you said this makes the result a TEXT value, not a real number or date.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,550
Members
452,927
Latest member
rows and columns

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top