View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.misc
peyman peyman is offline
external usenet poster
 
Posts: 189
Default pulling out Numbers

hi Ron,
the problem in Mikes macro is , it removes the zero at the begining of a
numbers after pulling out them,like:
aab0125 turns to 125 instead of 0125

"Ron Rosenfeld" wrote:

On Tue, 21 Aug 2007 11:18:02 -0700, Mike H
wrote:

With a macro:-

Sub removeletters()
For Each cell In Selection
For a = 1 To Len(cell)
If Asc(Mid(cell, a, 1)) 47 And Asc(Mid(cell, a, 1)) < 59 Or _
Asc(Mid(cell, a, 1)) 64 And Asc(Mid(cell, a, 1)) < 91 Then _
newstring = newstring & Mid(cell, a, 1)
Next
cell.Value = newstring
ActiveCell.NumberFormat = "General"
newstring = ""
Next
End Sub



Your For/Next loop can be simplified:


For a = 1 To Len(cell)
If Mid(cell, a, 1) Like "#" Then
newstring = newstring & Mid(cell, a, 1)
End If
Next


--ron