How Can I Remove a Character?

  • Thread starter Thread starter Anne
  • Start date Start date
A

Anne

I want to remove the formatting from a series of phone
numbers (888-777-4444) to make it a straight number
(8887774444).

I know I've come across this before but can't locate it
for anything.

Thanks in advance -
 
Hi Anne ,

Try the following function by passing the phone number as strInput and "-"
as strCompare. The returned string should have the dashes removed.

Jamie

-----------------------------------------------------------
Public Function funRemChar(strInput As String, ByVal strCompare As String)
As String

On Error Resume Next

Look:
If VBA.InStr(strInput, strCompare) = 0 Then
funRemChar = strInput
Else
strInput = VBA.Left$(strInput, VBA.InStr(strInput, strCompare) - 1) _
& VBA.Right$(strInput, VBA.Len(strInput) - VBA.InStr(strInput,
strCompare))
GoTo Look
End If

End Function
 
Anne said:
I want to remove the formatting from a series of phone
numbers (888-777-4444) to make it a straight number
(8887774444).

I know I've come across this before but can't locate it
for anything.


In A2K or later, you can use the Replace function to do
this:

Replace(phonefield, "-", "")
 
Back
Top