Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Like Operator Error

Are you saying that the pattern you want to match is

"[0-9Aa][0-9Dd][0-9Tt]##-#[Aa-Zz][Aa-Zz]"

Where is your wildcard?

Barb Reinhardt




"RyanH" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Like Operator Error

I'm not sure what you mean by wildcard? I am wanting to ensure that each
cell has one of these formats:

#####-# + 2 Letters
#####-## + 2 Letters
ADT##-# + 2 Letters
ADT##-## + 2 Letters

I don't want the 2 Letters and the "ADT" to be case sensitive, I need a
range of Aa-Zx. Is this not the correct way to code a alphabetic range
[Aa-Zz]?
--
Cheers,
Ryan


"Barb Reinhardt" wrote:

Are you saying that the pattern you want to match is

"[0-9Aa][0-9Dd][0-9Tt]##-#[Aa-Zz][Aa-Zz]"

Where is your wildcard?

Barb Reinhardt




"RyanH" wrote:

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Like Operator Error

Not, it is not the correct way to code the alphabetic range you want... see
my other post for the correct way to code it.

--
Rick (MVP - Excel)


"RyanH" wrote in message
...
I'm not sure what you mean by wildcard? I am wanting to ensure that each
cell has one of these formats:

#####-# + 2 Letters
#####-## + 2 Letters
ADT##-# + 2 Letters
ADT##-## + 2 Letters

I don't want the 2 Letters and the "ADT" to be case sensitive, I need a
range of Aa-Zx. Is this not the correct way to code a alphabetic range
[Aa-Zz]?
--
Cheers,
Ryan


"Barb Reinhardt" wrote:

Are you saying that the pattern you want to match is

"[0-9Aa][0-9Dd][0-9Tt]##-#[Aa-Zz][Aa-Zz]"

Where is your wildcard?

Barb Reinhardt




"RyanH" wrote:

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


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Like Operator Error

I think you want this pattern...

"[0-9Aa][0-9Dd][0-9Tt]##-#[A-Za-z][A-Za-z]"

Upper case and lower case ranges (separated by a dash) are specified
individually).

--
Rick (MVP - Excel)


"RyanH" wrote in message
...
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




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Like Operator Error

Sorry about that Rick. I was looking for that post and couldn't find it.
That is exactly what I was looking for!

Thanks for saving me again, you're the man!
--
Cheers,
Ryan


"Rick Rothstein" wrote:

I think you want this pattern...

"[0-9Aa][0-9Dd][0-9Tt]##-#[A-Za-z][A-Za-z]"

Upper case and lower case ranges (separated by a dash) are specified
individually).

--
Rick (MVP - Excel)


"RyanH" wrote in message
...
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



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
vba using the OR operator Mona Excel Programming 8 February 27th 07 11:29 PM
Compare Validation Operator give error tskogstrom Excel Programming 0 December 1st 06 12:27 AM
corrupt program or file? How to tell? Or is it operator error? [email protected] Excel Discussion (Misc queries) 6 January 17th 06 12:40 PM
Syntax error (missing operator) in query expression '6 Wescott Rd# shealy Excel Discussion (Misc queries) 0 June 9th 05 09:53 PM
OR Operator Freddy Excel Worksheet Functions 2 April 17th 05 06:11 PM


All times are GMT +1. The time now is 12:20 PM.

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

About Us

"It's about Microsoft Excel"