Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trouble with wildcards

Status
Not open for further replies.

Luis939

MIS
Feb 28, 2003
453
US
i'm having a little trouble with defining what my wildcards should be for my conditional statements, i need to ensure that all cells are not "" (null/blank) or MUST be in the form city, state intials (ID) or city, state - street (id)
for example valid strings are newark, nj (1234) or newark, nj - market st. (1234), there might be some text after the ID also

i tried
If activecell.value = "" Or Not (activecell.value Like "*, ?? (*)*") And Not (activecell.value Like "*, ?? - * (*)*") Then Exit Do

would this be correct, should that "And" be an "Or",
and should it be "*, ?? (*)*" or "*, ?? (*) *" because im not sure where that last * should be, i keep gettin conflicting results
Also it would help if there is a way of eliminiating extra blanks within my text, i want every word to be seperating by just one blank, i'm trying to match strings so i dotn want to get an error whenever i try to find whether "My String" is equal to "My String" becuase ill get an error, thanks!!!

 
Hi 4335,

Assuming that all cells are not "" (null/blank) or MUST be in the form etc. means that empty cells are OK but that all non-empty cells must be in one of the formats you mention ...

There are three conditions. At most one of them can be true. If one of them is true you want to Exit Do (or whatever). If none of them are true you want to do something else. The "Not"s just confuse; more simply, try:

Code:
If activecell.value = "" Or activecell.value Like "*, ?? (*)*" Or activecell.value Like "*, ?? - * (*)*" Then Exit Do

Your wildcard strings look OK. If you want to lose multiple spaces then replace activecell.value with WorksheetFunction.Trim(activecell.value)

Enjoy,
Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top