Add leading zeros based on IF text

bosco72

New Member
Joined
Aug 2, 2011
Messages
7
I need either a foumula or macro to add leading zeros to a number based on text in another column

Column A is the original number
Column B is blank and where I want my result to go leaving column A original
Column C is where the text is that the leading zeros will be based on

A1 = 14M3652100
B1 = Blank
C1 = If this column has text "ASP" or "POSMOS" or "ANISON" I need B1 to result in 0014M3652100

Thanks for any help. Sounds easy but I am new at this......
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
You don't say how many leading zeros. Is it the same for all 3? Is it to make the string a certain length?

You can start with something like:
B1= =if(or(C1="ASP",C1="POSMOS",c1="ANISON"),"00"&A1,A1)
 
Upvote 0
Yep it's 2 zeros, no not to make a certain length it needs to have those 2 zeros to make a certain format so when we search in an external system those with the ASP, POSMOS or ANISON need to have the zeros added in order to find them. that formula worked great! Thank you!
 
Upvote 0
glad I could help. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,577
Members
449,039
Latest member
Arbind kumar

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