Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Clean Up Phone and Fax Numbers

Here's a macro I have for cleaning up fax (or phone) numbers. Our sales
people enter all kinds of random items in the fax field and I use this to
take out all the extra info. I have three questions.

1. How can I take out the double quotation symbol?
2. How can I take out alphabetic characters without listing every single
letter? or is that possible?
3. Is there a better way to do this?

Thank you,
Billy Rogers
Dallas, TX

Sub CleanUP()
Dim c As Range

For Each c In Selection.Cells
c = Replace(c, " ", "")
c = Replace(c, "-", "")
c = Replace(c, ".", "")
c = Replace(c, ",", "")
c = Replace(c, "'", "")
c = Replace(c, "*", "")
c = Replace(c, ";", "")
c = Replace(c, "#", "")
c = Replace(c, "@", "")
c = Replace(c, "^", "")
c = Replace(c, "(", "")
c = Replace(c, ")", "")
c = Replace(c, "$", "")
c = Replace(c, "%", "")
c = Replace(c, "_", "")
c = Replace(c, "\", "")
c = Replace(c, "|", "")
c = Replace(c, "/", "")
c = Replace(c, "<", "")
c = Replace(c, "", "")
c = Replace(c, "?", "")
c = Replace(c, "!", "")
c = Replace(c, "+", "")
c = Replace(c, "`", "")
c = Replace(c, "~", "")
c = Replace(c, "&", "")
c = Replace(c, ":", "")
c = Replace(c, "[", "")
c = Replace(c, "]", "")
c = Replace(c, "{", "")
c = Replace(c, "}", "")



Next

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Clean Up Phone and Fax Numbers

I found this code someone else posted that seems to do what I want and runs
much much quicker than my macro. I'm sorry i lost the post where I found
this and can't give the name of the person who posted it originally. I
renamed it ( the original name was Sub Stripper). It gives you an input box
to determine whether you want to remove letters or numbers. If you choose
letters it removes any non number items-symbols, punctuation,spaces,dashes
etc. It works very well.

Sub RemoveLettersOrNumbers()


Dim myRange As Range
Dim Cell As Range
Dim myStr As String
Dim i As Integer
With Application
..ScreenUpdating = False
..Calculation = xlManual
End With
On Error Resume Next
Set myRange = Range(ActiveCell.Address _
& "," & Selection.Address) _
..SpecialCells(xlCellTypeConstants)
If myRange Is Nothing Then Exit Sub
If Not myRange Is Nothing Then
Which = InputBox("Strip Numbers - Enter 1" & vbCrLf & _
"Strip Letters - Enter 2")
If Which = 2 Then
For Each Cell In myRange
myStr = Cell.Text
For i = 1 To Len(myStr)
If (Asc(UCase(Mid(myStr, i, 1))) < 48) Or _
(Asc(UCase(Mid(myStr, i, 1))) 57) Then
myStr = Left(myStr, i - 1) _
& " " & Mid(myStr, i + 1)
End If
Next i
Cell.Value = Application.Trim(myStr)
Next Cell
Selection.Replace What:=" ", _
Replacement:="", Lookat:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
ElseIf Which = 1 Then
For Each Cell In myRange
myStr = Cell.Text
For i = 1 To Len(myStr)
If (Asc(UCase(Mid(myStr, i, 1))) < 65) Or _
(Asc(UCase(Mid(myStr, i, 1))) 90) Then
myStr = Left(myStr, i - 1) _
& " " & Mid(myStr, i + 1)
End If
Next i
Cell.Value = Application.Trim(myStr)
Next Cell
End If
End If
With Application
..Calculation = xlAutomatic
..ScreenUpdating = True
End With



End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
phone numbers Tony R New Users to Excel 4 August 13th 07 04:44 PM
Convert phone numbers with dashes in them to just numbers J H Excel Discussion (Misc queries) 2 June 23rd 06 06:56 PM
Convert phone numbers with dashes in them to just numbers J H Excel Discussion (Misc queries) 2 June 23rd 06 02:40 AM
How can I cross reference phone numbers with existing phone numbe. John Excel Discussion (Misc queries) 1 February 11th 05 04:39 PM
Words > Numbers (i.e. Vanity Phone Numbers) function Don Excel Worksheet Functions 1 December 29th 04 06:10 PM


All times are GMT +1. The time now is 12:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"