ajhez
06-22-2017, 04:46 AM
Hi all
I'm trying to remove special characters within a selection in Excel (special characters being anything that cannot be used in a file name for saving purposes - e.g. "`", "!", "@", "#", "$", ";", "^", "(", ")", "_", "-", "=", "+", _
"{", "[", "}", "]", "\", "|", ";", ":", "'", """", ",", "<", ".", ">", "/", "?".
I'm using the below, but can only get it to work for "/" how do I expand fnd to encompass as many of the special characters as possible?
I need to retain it to work based on my selection rather than a fixed group of cells/columns/rows.
Sub FindandReplace()
Dim fnd As Variant
Dim rplc As Variant
fnd = "/"
rplc = ""
Selection.Replace What:=fnd, Replacement:=rplc, _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _
SearchFormat:=False, ReplaceFormat:=False
End Sub
Thanks,
AJHEZ
I'm trying to remove special characters within a selection in Excel (special characters being anything that cannot be used in a file name for saving purposes - e.g. "`", "!", "@", "#", "$", ";", "^", "(", ")", "_", "-", "=", "+", _
"{", "[", "}", "]", "\", "|", ";", ":", "'", """", ",", "<", ".", ">", "/", "?".
I'm using the below, but can only get it to work for "/" how do I expand fnd to encompass as many of the special characters as possible?
I need to retain it to work based on my selection rather than a fixed group of cells/columns/rows.
Sub FindandReplace()
Dim fnd As Variant
Dim rplc As Variant
fnd = "/"
rplc = ""
Selection.Replace What:=fnd, Replacement:=rplc, _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _
SearchFormat:=False, ReplaceFormat:=False
End Sub
Thanks,
AJHEZ