Formula to convert or make to 3 digit always

kumar1803

Board Regular
Joined
Jan 7, 2015
Messages
110
Hello,

Please help me convert the following number in the format provided below:

ALCET1010036303-15


Should be:

ALCET1010036303-015

AND

ALCET1010036580-3

Should be:

ALCET1010036580-003
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Hi,

Something like this?


Excel 2010
ABCD
1ALCET1010036303-15ALCET1010036303-015ALCET1010036303-015
2ALCET1010036580-3ALCET1010036580-003ALCET1010036580-003
Sheet1
Cell Formulas
RangeFormula
B1=LEFT(A1,SEARCH("-",A1))&TEXT(RIGHT(A1,LEN(A1)-SEARCH("-",A1)),"000")
D1=LEFT(A1,16)&TEXT(RIGHT(A1,LEN(A1)-16),"000")


Use C column formula if value left of hyphen is variable in length.
Use D column formula if value left of hyphen is always 15 characters.
 
Last edited:
Upvote 0
Assuming there are always the same number of characters before the dash (like in your two examples), then this formula should do what you want...

=REPLACE(A1,17,3,TEXT(MID(A1,17,3),"000"))
 
Upvote 0
Rick, I was trying (without much luck) to see if there was a custom format to do this?
 
Upvote 0
Rick, I was trying (without much luck) to see if there was a custom format to do this?

I was looking into it too...maybe someone can post the custom format.
 
Upvote 0
Rick, I was trying (without much luck) to see if there was a custom format to do this?
You can only format cells containing numbers in Excel (well, theoretically you can format text, but only by adding more text via the custom format)... the OP's cells contain a mix of text and numbers meaning Excel sees the cell as containing text. If the OP wants to physically change the cells themselves (rather than having the fixed text in another cell), then we would need to use VB code to do that.
 
Upvote 0
You can only format cells containing numbers in Excel (well, theoretically you can format text, but only by adding more text via the custom format)... the OP's cells contain a mix of text and numbers meaning Excel sees the cell as containing text. If the OP wants to physically change the cells themselves (rather than having the fixed text in another cell), then we would need to use VB code to do that.

Thanks Rick for letting us know.
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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