pattern matchimg in VBA Excel using LIKE operator
Maybe:
Function MyIsDate(xDate as String) as Boolean
MyIsDate = xDate like "##/##/####" or xDate like "#/##/####" _
or xDate like "##/#/####"
End Function
What about the built in IsDate function?
--
Regards,
Tom Ogilvy
wrote in message
oups.com...
I have cells containing a series of dates in the format: 8/21/2006 or
11/6/2005 or 11/23/2005 or 8/7/2006. I want to identify these cells by
the pattern in a VBA module.
I have tried these listed below and variations without success:
Function IsDate(xDate As String) As Boolean
If xDate Like "*/*/*" Then
IsDate = True
Else
IsDate = False
End If
End Function
Function IsDate(xDate As String) As Boolean
If xDate Like "*/*/####" Then
IsDate = True
Else
IsDate = False
End If
End Function
Function IsDate(xDate As String) As Boolean
If xDate Like "*[/]*[/]*" Then
IsDate = True
Else
IsDate = False
End If
End Function
I have also declared Option Compare Text and not declared Option
Compare Text.
Any ideas?
|