Removing Non-Alphanumeric Characters

gray_b

New Member
Joined
Apr 17, 2019
Messages
34
Office Version
  1. 365
Platform
  1. Windows
Removing Non-Alphanumeric Characters.

Been trying to use the code in thread at Removing Non-Alphanumeric Characters (without using macros or script!)

But I cannot get anything to work

as in the code associated with "Function CleanCode" also the code "=UPPER(CLEAN(SUBSTITUTE("

I want to clean out Non Alpha Chjaracters such as
(LA73A) = LA73A
‘white’ = white
though) = through
UK’s = UKs

Any help and guidance plz
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Why doesn't it work? Are you using it as: =CleanCode(A1) for example?
 
Upvote 0
You still haven't said why it doesn't work.
Ok - I have found the answer to my problem.

1 - My original data had row1 formatted as a 'text' row. No matter what i did nothing worked. However all the other rows were formatted as 'general'. Changed cell formatting to 'general' and it worked OK.
2 - But in copying the original code =CleanCode(A1) from cell B1, and pasting anywhere on the sheet, nothing happened. As it copies the formatting of the cells with it. In setting the copied cell to 'general' it worked OK.
3- My whole worksheet now set to 'general' cell formatting

Many thanks for assistance.

Maybe the first line of coding should have set the cells to the correct cell formatting required. But maybe due to my in experience as well.
 
Upvote 0
Solution
Here is a way using dynamic array formulas.

GRAY
IJ
32(LA73A)LA73A
33‘white’ dogwhite dog
34though)though
35UK’sUKs
Data
Cell Formulas
RangeFormula
J32:J35J32=ALPHANUMONLY(I32:I35)
Dynamic array formulas.


Here are the formulas.

ALPHANUMONLY
Excel Formula:
=LAMBDA(vector,
    MAP(vector,
        LAMBDA(t,
            LET(
                x,ARRAYFROMTEXT(t),
                TRIM(CLEAN(TEXTJOIN("",,FILTER(x,(ISALPHA(x)+ISNUMBER(x+0)+(x=" "))>0))))
            )
        )
    )
)

ARRAYFROMTEXT
Excel Formula:
=LAMBDA(text,[to_rows],
    LET(
        a,text,
        n,LEN(a),
        r,MID(a,SEQUENCE(n),1),
        IF(ISOMITTED(to_rows),r,IF(to_rows,r,TRANSPOSE(r)))
    )
)

ISALPHA
Excel Formula:
=LAMBDA(text,
    LET(
        c,CODE(text),
        ((c>64)*(c<91))+((c>64)*(c<91))+((c>96)*(c<123))>0
    )
)
 
Upvote 0

Forum statistics

Threads
1,215,480
Messages
6,125,047
Members
449,206
Latest member
Healthydogs

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