Padding Zeros in the middle of a string

DShack

Board Regular
Joined
Jan 15, 2014
Messages
64
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hello All,

I am trying to pad zeros to the middle of this string where the 122 is at. I have tried several different things for example this formula =LEFT(A2,11)&TEXT(MID(A2,12,LEN(A2)),"00000") but nothing seems to be working. I have an excel document that is over 300K rows so a formula would be great to fix this issue. Additionally, the middle record (122 currently) is either 2 or 3 characters and I need it to be 5 characters in length.
Please i need some help! Thank you Everyone!

1301-08020-122-341773-0000-000
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Will the number always start at the 12th character?
 
Upvote 0
Yes, it will always start in the 12th character.
 
Upvote 0
Or a slightly simpler formula
Excel Formula:
=REPLACE(A2,12,0,REPT(0,6-FIND("-",MID(A2,12,100))))
 
Upvote 0
Thank you Fluff, both of these work excellent! I should have thought of the replace formula.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,901
Messages
6,122,157
Members
449,068
Latest member
shiz11713

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