View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default Matching strings with a pattern

On Sat, 27 Mar 2010 22:55:14 -0400, "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)


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.
--ron