Thread: Remove Dashes
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default Remove Dashes

Here is one method using VBA.

Sub RemoveAlphas()
' Remove alpha characters from a string.

Dim intI As Integer
Dim rngR As Range, rngRR As Range
Dim strNotNum As String, strTemp As String
Set rngRR = Selection.SpecialCells(xlCellTypeConstants, _
xlTextValues)
For Each rngR In rngRR
strTemp = ""
For intI = 1 To Len(rngR.Value)
If Mid(rngR.Value, intI, 1) Like "[0-9]" Then
strNotNum = Mid(rngR.Value, intI, 1)
Else: strNotNum = ""
End If
strTemp = strTemp & strNotNum
Next intI
rngR.Value = strTemp
Next rngR
End Sub


Gord Dibben MS Excel MVP


On Thu, 10 Aug 2006 17:34:11 -0700, "Striker" wrote:

I have about 4,000 cells in Excel 200 that have phone numbers formatted as
(123)456-7890. I would like to remove everything except the numbers so that
they come out like 1234567890, what is a good way to do this?

Thanks