Skip to content

Instantly share code, notes, and snippets.

@rs77
Last active August 29, 2015 14:21
Show Gist options
  • Save rs77/5231aafd7584240d401c to your computer and use it in GitHub Desktop.
Save rs77/5231aafd7584240d401c to your computer and use it in GitHub Desktop.
Function AlphaNumericOnly(strSource As String) As String
Dim i As Integer
Dim strResult As String
For i = 1 To Len(strSource)
Select Case Asc(Mid(strSource, i, 1))
Case 32, 48 To 57: 'include 32 if you want to include space
strResult = strResult & Mid(strSource, i, 1)
End Select
Next
AlphaNumericOnly = Strings.Trim(strResult)
End Function
Sub CleanAll()
Dim rng As Range
For Each rng In Sheets("CustomersWithNoPhoneinAddressRe").Range("C2:E5000").Cells 'adjust sheetname and range accordingly
rng.Value = AlphaNumericOnly(rng.Value)
Next
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment