Removing Non-Alphanumeric Characters (without using macros or script!)

ellison

Active Member
Joined
Aug 1, 2012
Messages
356
Office Version
  1. 365
Platform
  1. Windows
Arrghhhhhhhhh I've been trying to do this for weeks!

We have a report which arrives with 30,000 lines of different part numbers.

And we need to extract just the alpha(A-Z or a-z) numeric (0-9) characters from it, leaving out all of the dahses, slashes, underscores, spaces and everything else that people manage to include.
For example

AS-B___8/4%9-016d needs to be ASB849016D

Ab'D-A/9(00)-7[5-M-T8"16 needs to be ABDA90075MT816

The only solutions I can find involve macros, script & UDF's....and that's just about smashed my learning to pieces!!! :confused:

Would anybody have a version which could help us to get this done using those?

PS Wonderful site gents, many many thanks!
 
If I dont want spaces between the names to be deleted, what should I do. Spaces before the name and after the name can be removed, but not in between the names please

Very difficult and messy to do this without VBa.

Try this UDF

To use this you need to do this.

1/. In Excel, with your workbook open, press Alt+f11 this will take you to the VBa Editor.

2/. With the "Insert" Tab choose "Module"

3/. In the resulting window paste all of the following code
Code:
Function CleanCode(Rng As Range)
    Dim strTemp As String
    Dim n As Long
    
    For n = 1 To Len(Rng)
        Select Case Asc(Mid(UCase(Rng), n, 1))
            Case 48 To 57, 65 To 90
                strTemp = strTemp & Mid(UCase(Rng), n, 1)
        End Select
    Next
    CleanCode = strTemp
End Function

Use in Excel like so ...
Code:
=CleanCode(A1)
 
Upvote 0

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
You do realise you have jumped into a thread that is 7 years old !!
Have you looked at the TRIM function

Code:
=TRIM(A1)

Will remove leading and trailling spaces
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,333
Members
452,636
Latest member
laura12345

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