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

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

onlyadrafter

Well-known Member
Joined
Aug 19, 2003
Messages
5,703
Platform
  1. Windows
Hello,

how about starting with

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

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

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
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
 

Forum statistics

Threads
1,141,219
Messages
5,705,086
Members
421,378
Latest member
CarlosDuran

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
Top