Wildcards for dates

L

Legacy 57334

Guest
I have three columns with data as follows:

01/09/2007 | 5 | 06/09/2007
| 4 | 01/01/1900

If the value isnt set in column A then Column C shows this dummy date value.
I have some VBA which is serching for the data in ColumnC and exports it. The problem is that i want it to export "Unknown" if the default is displayed. How can i do that?

I tried an If/ElSE statment and used wildcards as "??/??/1900" but that didnt work.

Thanks
Joel
 

Some videos you may like

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Damon Ostrander

MrExcel MVP
Joined
Feb 17, 2002
Messages
4,239
Hi Joel,

To use wildcards you need the VBA Like operator. Example:

Code:
If Range("C4").Text Like "??/??/1900" Then
   'Export "Unknown"
Else
   'Export C4 value
End If

But if your intent is simply to determine if the year is 1900 you could use:

Code:
If Year(Range("C4").Value) = 1900  Then
   'Export "Unknown"
Else
   'Export C4 value
End If

Note the use of the Value and Text properties of the cell. This is because the underlying value of the cell (the Value property) is not the text string "01/01/1900" but rather the number of days elapsed since 1/0/1900, or a value of 1. The Text value (i.e., what is displayed in the cell) is the result of formatting the underlying value as mm/dd/yyyy.

I hope this helps.

Damon
 
L

Legacy 57334

Guest
it works AND Youve explained teh reason brilliantly, thank you!
 

Watch MrExcel Video

Forum statistics

Threads
1,122,207
Messages
5,594,840
Members
413,944
Latest member
3xc3ln00b

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
Top