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
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
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
 
Upvote 0

Forum statistics

Threads
1,214,636
Messages
6,120,666
Members
448,977
Latest member
moonlight6

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