Matching strings with a pattern
Thanks a ton, everyone. I tried Rick's solution and it worked. I will
try out and study Ron's Regex solution next.
Regards,
Raj
On Mar 28, 7:55*am, "Rick Rothstein"
wrote:
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
--
Rick (MVP - Excel)
"Raj" wrote in message
...
Hi,
I have cells containing strings of the type "Mumbai - 400078" and
"Belgaum - 590011" with the following pattern:
Alphabetic string followed by space followed by hyphen followed by
space and then a numeric string. I want to fill such cells with a
color (interior.colorindex)? How do I identify such cells to the code?
Thanks in Advance for the help.
Regards,
Raj
|