Doing a search and replace is

laredotornado

New Member
Joined
Oct 16, 2014
Messages
3
Hi,

I'm using Excel 14.4.4 on Mac 10.9.5. I have an .xls file and one of the columns has cell values like so ...

dob_062601

I want to remove the "dob_" in front of each value, but at the same time, preserve any leading zeroes that may be left over. When I do a search and replace for the "dob_" string, replacing it with an empty string (""), the leading zeroes disappear. Any idea how I can preserve them?
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
dob_062601

I want to remove the "dob_" in front of each value, but at the same time, preserve any leading zeroes that may be left over. When I do a search and replace for the "dob_" string, replacing it with an empty string (""), the leading zeroes disappear. Any idea how I can preserve them?
Try using an apostrophe (') in the "Replace with" field instead of the empty string.
 
Upvote 0
Try using an apostrophe (') in the "Replace with" field instead of the empty string.

Hi,

I think I'm not explaining what I want to do well. I have cells taht look like

dob_060201

and I want the final value to be

060201

How do I do that? I don't want extra apostrophes in there, I just want that "dob_" string removed and the leading zeroes preserved.
 
Upvote 0
Hi,

I think I'm not explaining what I want to do well. I have cells taht look like

dob_060201

and I want the final value to be

060201

How do I do that? I don't want extra apostrophes in there, I just want that "dob_" string removed and the leading zeroes preserved.

You can try the following formula if your data is in Cell A4:

Code:
=RIGHT(A4;LEN(A4)-FIND("_";A4))

If you have difficulty applying the formula, try to replace ";" with "," in the formula

Code:
=RIGHT(A4,LEN(A4)-FIND("_",A4))

The FIND function find the index of "_" character in your text, which is located in cell A4. The RIGHT function will take a substring from the right with a number of characters.

Hope that work for you.
 
Last edited:
Upvote 0
Thanks for this. What if I want to apply this to an entire column's worth of data? Also, I'm submitting the XLS file to an application that processes it, and I'd like taht application to read the values in the cell as "######" as opposed to read a formula. Would applying the formula you suggsted achieve that?
 
Upvote 0
I don't want extra apostrophes in there
You won't see it and Excel will ignore it in any formulas that use the cell... the leading apostrophe will be a signal to Excel to treat the value as Text even though the cell is formatted as General.
 
Upvote 0
Thanks for this. What if I want to apply this to an entire column's worth of data? Also, I'm submitting the XLS file to an application that processes it, and I'd like taht application to read the values in the cell as "######" as opposed to read a formula. Would applying the formula you suggsted achieve that?

Try this instead:

Code:
=IFERROR(RIGHT(A4;LEN(A4)-FIND("_";A4));"error")
 
Upvote 0

Forum statistics

Threads
1,215,459
Messages
6,124,947
Members
449,198
Latest member
MhammadishaqKhan

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