Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default pattern matchimg in VBA Excel using LIKE operator

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?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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?



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Does Excel have an operator similar to LIKE? 19nigel91 Excel Discussion (Misc queries) 11 May 26th 08 11:02 AM
XOR operator in Excel lurchot Excel Discussion (Misc queries) 6 February 14th 08 05:13 PM
have Excel retrieve conditional operator ( < = ) from a cell [email protected] Excel Worksheet Functions 1 May 17th 07 07:16 PM
MAJOR BUG: Excel operator precedence is wrong P Keenan Excel Worksheet Functions 5 June 23rd 06 02:18 PM
Difference operator in Excel VBA londono001 Excel Programming 1 September 20th 05 09:47 AM


All times are GMT +1. The time now is 03:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"