Replace Illegal Characters Assistance

gbc123

New Member
Joined
May 6, 2004
Messages
30
Hi,

I have an output, e.g column A, which contains a text output but also characters that I want to get rid of e.g *,;*:,/ as well as the presence of any tabs or carraige returns.

Sample text (A1) shows exactly as

Mr A Smith
13 Jones Road;
Bicester,BS11

I need to change this to (into column B) as
Mr A Smith 13 Jones Road Bicester BS11

I have searched in vain and time is now against me.

Any help gratefully received.

Thanks.

G.
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Hello,

how about starting with

=SUBSTITUTE(A1,CHAR(10)," ")

then maybe doing a manual find and replace, if you're in a hurry?
 
Upvote 0
Hi

Here's a VBA solution using a UDF - needs to be pasted into a standard module in your workbook:

Code:
Function StripNonAlphaNums(ByVal strRef As String) As String
Dim b() As Byte, i As Long, temp As String
b = StrConv(strRef, vbFromUnicode)
temp = ""
For i = LBound(b) To UBound(b)
    Select Case b(i)
        Case 97 To 122, 65 To 90, 48 To 57, 39, 32
            temp = temp & ChrW$(b(i))
        Case 10
            temp = temp & " "
    End Select
Next i
StripNonAlphaNums = temp
End Function

Use like a normal function:

=StripNonAlphaNums(A1)

Best regards

Richard
 
Upvote 0

Forum statistics

Threads
1,217,316
Messages
6,135,811
Members
449,965
Latest member
Ckl43

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