View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Find specific text in a string

Dim rng as Range, cell as Range
set rng = Columns(1).SpecialCells(xlConstants, xlTextValues)
for each cell in rng
if left(cell.Text,1).Value = "(" then
cell.ClearContents
end if
Next

assumes that the telephone numbers are entered as strings as shown and the
(XXX)XXX-XXXX appearance is not produced by formatting.

--
Regards,
Tom Ogilvy

"Kilcup " wrote in message
...
Dear friends,

I am attempting to use a macro to locate cells that contain phone
numbers. The phone numbers follow this format: (XXX)XXX-XXXX and are
strings. Also, all of the numbers are in column A.

Here is how the info is listed:

Joe Samuel
123 Lilly Lane
Your town AL 55555
(XXX)XXX-XXXX
Sally Smart
3456 Her Lane
My Town AL 55555
(XXX)XXX-XXXX

I am trying to create code that will a) locate the fields that contain
the phone numbers and then b) clear that cell, moving on to the next
cell, etc. I suppose the best thing to do would be simply to locate
fields where the first character is a parenthesis, then clear it.

Can anyone help?

Thanks.


---
Message posted from http://www.ExcelForum.com/