'set a range assuming that data starts in A2 and is vertically contiguous
Dim PhoneRange as Range
Set PhoneRange = Range(Cells(2,1), Cells(2,1).End(xlDown))
'For Each...Next loops thru each object in a collection
For Each c In PhoneRange
'references the object and holds that object's node for associated properties and methods
With c
sOut = ""
bPrev = False
For i = 1 To Len(.Value)
'.value is identical to c.value but it is more efficient -- it is the value of a single range object in the PhoneRange
sByte = Mid(.Value, i, 1)
Select Case sByte
Case "0" To "9"
sOut = sOut & sByte
bPrev = True
Case Else
If bPrev Then _
sOut = sOut & "-"
bPrev = False
End Select
'assign the reconstructed string to c.Value
.Value = sOut
End With
Next
Hi Skip,
I've got a test file, with one column of code titled PhoneRange, with data beginning in A2. This data can have some weird stuff in it, besides numbers, I'd just like to be able to remove the non numeric characters.
Thanks,
Andy