DRSteele

Remove Unwanted Characters from a Textstring

DRSteele

Well-known Member
Joined
Mar 31, 2015
Messages
2,640
Office Version
  1. 365
Platform
  1. Windows
DRSteele submitted a new Excel article:

Remove Unwanted Characters from a Textstring - We can get rid of things like punctuation from a textstring in a cell.

Getting rid of unwanted characters in a cell's textstring can be achieved easily by creating a Table of acceptable UNICODEs and their corresponding UNICHARs. The Table (here named T_codes) can be expanded or contracted as needed. Here, we have just the usual set of English letters (26 Upper Case and 26 Lowers plus the Numerals), but it can be altered to suit other needs.

Also listed is a formula that spills down 50,000 rows to show ALL the UNICODEs. It might be more manageable to look at...

Read more about this Excel article...
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Hi Don
I would just suggest instead of using TEXTJOIN & specifying a null joiner, swap to CONCAT instead.
Excel Formula:
=CONCAT(IFNA(UNICHAR(XLOOKUP(UNICODE(MID(C1,SEQUENCE(LEN(C1)),1)),T_codes[Permitted UNICODE],T_codes[Permitted UNICODE])),""))
 
Actually, if you are making a list of allowed characters, do you need their codes as well?

22 09 24.xlsm
BC
1text string:gfpak(&LR--Ysdf/fhV+125,Ufd*^@3+
2reduced text string:gfpakLRYsdffhV125Ufd3
3
4
5Characters
60
71
82
93
104
115
126
137
148
15A
16B
17C
18D
19E
20F
21G
22H
23I
24J
25K
26L
27M
28N
29O
30P
31Q
32R
33S
34T
35U
36V
37W
38X
39Y
40a
41b
42c
43d
44e
45f
46g
47h
48i
49j
50k
51l
52m
53n
54o
55p
56q
57r
58s
59t
60u
61v
62w
63x
64y
65
Sheet3
Cell Formulas
RangeFormula
C2C2=LET(t,MID(C1,SEQUENCE(LEN(C1)),1),CONCAT(IF(ISNUMBER(FIND(t,CONCAT(Allowed[Characters]))),t,"")))
 
All very good observations as usual, Peter. Thanks tons!
 

Forum statistics

Threads
1,216,503
Messages
6,131,022
Members
449,616
Latest member
PsychoCube

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