copy cell less special char

MartinL

Well-known Member
Joined
Oct 16, 2008
Messages
1,141
Office Version
  1. 365
Platform
  1. Windows
sorry for the confusing title

what I want to do is make B1 = A1 less any special characters

so If A1 = apple/green
I want B1 = "apple green"

special characters are any characters that windows will not accept as a save name
[FONT=Arial, Helvetica, sans-serif]* Asterisk[/FONT]
[FONT=Arial, Helvetica, sans-serif]< >[ ] Brackets[/FONT]
[FONT=Arial, Helvetica, sans-serif]= Equal sign[/FONT]
[FONT=Arial, Helvetica, sans-serif]+ Plus sign[/FONT]
[FONT=Arial, Helvetica, sans-serif]” Quotes[/FONT]
[FONT=Arial, Helvetica, sans-serif]\ / Slashes[/FONT]
[FONT=Arial, Helvetica, sans-serif], . : ; Comma, Period, Colon, Semicolon[/FONT]
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Hi there,

Try (Thanks for bigresource):

Code:
Function removeSpecial(sInput As String) As String
    Dim sSpecialChars As String
    Dim i As Long
    sSpecialChars = "\/:*?""<>|"
    For i = 1 To Len(sSpecialChars)
        sInput = Replace$(sInput, Mid$(sSpecialChars, i, 1), " ")
    Next
    removeSpecial = sInput
End Function
 
Upvote 0
thanks guys I was going down this route

Code:
=IF(ISERROR(REPLACE(C31,FIND({"*","<",">","[","]","=","+","\","/"},C31),1,"")),C4,REPLACE(C31,FIND({"*","<",">","[","]","=","+","\","/"},C31),1,""))
 
Upvote 0
You could use a formula, once you've installed MOREFUNC add-in:

http://xcell05.free.fr/downloads/Morefunc.zip

... an array formula, entered using Ctrl-Shift-Enter , like:
Code:
=TRIM(MCONCAT(IF((ISERROR(MATCH(MID(A1,ROW(INDIRECT("A1:A99")),1),{"[","]","<",">","=","+","""","/","\",",",".",":",";","*"},0))),MID(A1,ROW(INDIRECT("A1:A99")),1)," ")))
.. changing MID(A1 to point to whatever cell ref ( remember to change both of them in the formula ).
 
Upvote 0
Hi,

there's this method but I've only added 3 of the characters you need to remove - I'm sure you can complete it if it's suitable.

Code:
=(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"\",""),";",""),":",""))
 
Upvote 0
Hi,

there's this method but I've only added 3 of the characters you need to remove - I'm sure you can complete it if it's suitable.

Code:
=(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"\",""),";",""),":",""))
... only in Excel 2007 or higher, as there are more than 7 items to substitute.
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,299
Members
452,904
Latest member
CodeMasterX

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top