View Single Post
  #13   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben
 
Posts: n/a
Default remove non-numeric characters from a cell

Ammended code.......

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
On Error Resume Next
Set rngRR = Range(ActiveCell.Address & "," & Selection.Address) _
.SpecialCells(xlCellTypeConstants)

On Error GoTo endit
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
Exit Sub
endit:
MsgBox "No text values in range"
'End If
End Sub


Gord

On 15 Dec 2005 01:01:46 -0800, wrote:

Hi,
Good work on a highly missed function (should be included as default by
Microsoft, shouldn't it?)

When I go for the selected range function early in this post, this
works by design if I select a range. But if I select a single cell, the
function takes a go for the whole sheet.

Any clue?

Kind regards,
Bonavox