View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
RyanH RyanH is offline
external usenet poster
 
Posts: 586
Default Like Operator Error

I am getting an error on this single line of my code: Error #93, "Invalid
Pattern String". This If...Then Statement is used to scan Col.A and ensure
that the values have a particular format. It works great till it gets to
this number "18075-12". For some reason it is throwing the error and I don't
know why, any ideas?

Error Not .Cells(i, "A") Like "[0-9Aa][0-9Dd][0-9Tt]##-#[Aa-Zz][Aa-Zz]"


If (Not .Cells(i, "A") Like
"[0-9Aa][0-9Dd][0-9Tt]##-#[Aa-Zz][Aa-Zz]" And _
Not .Cells(i, "A") Like
"[0-9Aa][0-9Dd][0-9Tt]##-##[Aa-Zz][Aa-Zz]") And _
rngProductCodes.Find(What:=Right(.Cells(i, "A"), 2),
LookIn:=xlValues) Is Nothing Then

' highlight bad item number red and bold
With .Cells(i, "A").Font
.ColorIndex = 3
.Bold = True
End With
End If

--
Cheers,
Ryan