Check if a valid date?

Guanjin Peter

Active Member
Joined
May 21, 2008
Messages
429
I'm currently using the below code to check if it's blank. Actually I wanted to check if it is a valid date. I can't really use:
=IF(B1=dd-mm-yyyy,TEXT(WEEKDAY(B1),"dddd"),"")
so any idea?

Code:
=IF(B1="","",TEXT(WEEKDAY(B1),"dddd"))
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Dates are actually stored as Numbers in Excel (specifically, the number of days since 1/1/1900). So you can use the ISNUMBER function, i.e.

=IF(ISNUMBER(B1),TEXT(WEEKDAY(B1),"dddd"),"")
 
Upvote 0
there wasn't a need to specifcy true or false...that's strange.....

well it works wonders! Thanks!

It'll work for Vb code too?

like:
If Range("b1").Value = "ISNUMBER(B1)"
 
Last edited:
Upvote 0
If it is a number it is presumed true and if it is not then it is presumed false.

In if statements =TRUE and =FALSE are not really needed., but you could put:

=IF(ISNUMBER(B1)=TRUE,TEXT(WEEKDAY(B1),"dddd"),"")

But it is redundant.
 
Upvote 0
It'll work for Vb code too?

like:
If Range("b1").Value = "ISNUMBER(B1)"
Actually, VBA has an ISDATE function that works even better, as it differentiates numbers from dates (presumably by how they are formatted).

So, in VBA, you can use:
Code:
 If IsDate(Range("B1")) Then
...
 
Upvote 0

Forum statistics

Threads
1,214,429
Messages
6,119,433
Members
448,897
Latest member
ksjohnson1970

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