If you want to remove any number of characters from string in excel (Cell String) at a time, here I have a trick for you.
To get the desired result you have to write VBA code.
- Open the Microsoft Visual Basic Application.
- Click Insert>Module.
- Write the following Code.
Function RemoveSpecial(str As String) As String
Dim spchar As String
Dim i As Integer
spchar = "/* -#$9"
For i = 1 To Len(spchar)
str = Replace(str, Mid(spchar, i, 1), "")
Next
RemoveSpecial = str
End Function
Save and close the Microsoft Visual Basic Application Window.
In the above Code only (/,*,-,#,$,9) are removed from the string. You can add or delete character from the statement "spchar = "/* -#$9" " as per your requirement.
Now, You can call this "RemoveSpecial" function in any cell on same worksheet.
No comments:
Post a Comment