How to remove special characters from a cell

hsandeep

Well-known Member
Joined
Dec 6, 2008
Messages
1,226
Office Version
  1. 2010
Platform
  1. Windows
  2. Mobile
In coulumn C, the value is a text which contains Starting with 2 digit alphabets, separated by ONE special character "/" or "-", then 4 to 8 digit numericals then again separated by ONE special character "/" or "-", then 2 to 3 digit numericals.

Output required in column D = All text without special characters
and in column E = last numerical value (of 2 to 3 digit numericals)
and in column F = above last numerical value prefixed with a 0.
Note: blanks are not to considered
Ex:
cell C4=MH / 456789 - 187
cell D4=MH456789187
cell E4=0187

cell C4=YH / 1237 - 000
cell D4=MH1237000
cell E4=0000
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

Excel 2003
CDEF
3DataFull StringLast NumberLast Number with Zero
4MH / 456789 - 187MH4567891871870187
5YH / 1237 - 000YH12370000000000
Sheet1
Cell Formulas
RangeFormula
D4=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(C4,"/",""),"-","")," ","")
E4=TRIM(RIGHT(SUBSTITUTE(C4,"-",REPT(" ",50)),50))
F4="0"&E4
 
Upvote 0
I re-checked & it did not work.

Instead of C4, cell was DD4
Instead of D4, cell was DR4. Output was ok here.
But in cell DS4, the output was same as DD4. Last number did not appear.
There are values in DD4:DQ4.
What to do?
 
Upvote 0
Try these formulas...

First Part:
=TRIM(LEFT(RIGHT(SUBSTITUTE(" "&REPLACE(TRIM(SUBSTITUTE(SUBSTITUTE(DD4,"/"," "),"-"," ")),3,1,"")," ",REPT(" ",25)),50),25))

Last Part:
=0&TRIM(RIGHT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(DD4,"-"," "),"/"," ")," ",REPT(" ",25)),25))
 
Upvote 0
Try these formulas...

First Part:
=TRIM(LEFT(RIGHT(SUBSTITUTE(" "&REPLACE(TRIM(SUBSTITUTE(SUBSTITUTE(DD4,"/"," "),"-"," ")),3,1,"")," ",REPT(" ",25)),50),25))

Last Part:
=0&TRIM(RIGHT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(DD4,"-"," "),"/"," ")," ",REPT(" ",25)),25))

Last Part: OK
First Part: is not giving Last Number in the full string.
Second Part: It is Last Number. How to generate?
 
Upvote 0
Sorry, I completely misread what you wanted for that first part. Sal Paradise gave you a working formula for the first part.

First Part: =SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(D4,"/",""),"-","")," ","")

Last Part: =0&TRIM(RIGHT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(DD4,"-"," "),"/"," ")," ",REPT(" ",25)),25))
 
Upvote 0
Rick,
need second part also i.e. last number WITHOUT suffixing 0.
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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