VBScript to Remove Unwanted Dashes, Parentheses or Spaces From Phone Numbers


In my source file, the column for phone number has dashes and parentheses. Sincethe phone number won't integrate correctly to Dynamics with them, how can I remove them?

Use a VBScript to remove these unwanted characters. The complete script below uses the Replace function to replace any dash, parentheses or blank space with a null value, effectively removing it.

Dim PhoneStr

PhoneStr = SourceFields("Customers.Phone")

PhoneStr = Replace(PhoneStr,"-","")

PhoneStr = Replace(PhoneStr,"(","")

PhoneStr = Replace(PhoneStr,")","")

PhoneStr = Replace(PhoneStr," ","")

CurrentField = PhoneStr

This article was TechKnowledge Document ID:9714

TechKnowledge Content

Need more help?

Expand your skills
Explore Training
Get new features first
Join Microsoft Insiders

Was this information helpful?

Thank you for your feedback!

Thank you for your feedback! It sounds like it might be helpful to connect you to one of our Office support agents.