VBA macro to remove special characters from a string in excel

Simple VBA macro code to remove special characters from a string in excel. You can remove either all special characters or choose which special characters to remove from the string.

This macro retrieves each character from the string and checks whether it belongs to A-Z,a-z,0-9 or a space.If it belongs then it stores them into another string, else it ignores that. Finally, you will have a string without special characters.

Output:

excel-macro-output-remove-special-characters

 

 

 

 

 

Note: If you don’t want to remove any special character from the string, for example  $, then you can replace “[A-Za-z0-9  ] with “[A-Za-z0-9  $]” in above code.

About the Author

SRINI S

A passionate blogger. Love to share solutions and best practices on wordpress hosting, issues and fixes, excel VBA macros and other apps

Leave a Reply

Your email address will not be published. Required fields are marked *