Home |
Search |
Today's Posts |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If your number string is **always** six digits long, you can do this...
Sub ColorCells() Dim Cell As Range, YourRange As Range Set YourRange = Worksheets("Sheet2").Range("A1:C100") YourRange.Interior.ColorIndex = xlColorIndexNone For Each Cell In YourRange If Cell Like "* - ######" Then Cell.Interior.ColorIndex = 3 Next End Sub I interpreted the OP to mean by "alphabetic" that that string only contained letters. Yours will match any character, or even no character, in the first part of the string. As a matter of fact, the "*" is superfluous in your pattern. Good point Ron! I completely overlooked that. I just posted some corrected code for the OP (still using the Like operator test method). Going back to my original code though... what did you mean the "*" is superfluous in your pattern? If we leave it out, then this test will fail... If "Mumbai - 400078" like " - ######" Then Or did I miss the point of your comment? -- Rick (MVP - Excel) |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Pattern Matching | Excel Discussion (Misc queries) | |||
Pattern Matching using LIKE ? | Excel Programming | |||
VBE replace with pattern matching? | Excel Programming | |||
pattern matching possible? | Excel Worksheet Functions | |||
Pattern Matching with cells function | Excel Programming |