Seven Digit Number with Leading Zero's

Marc

Active Member
Joined
Feb 21, 2002
Messages
388
Hello Everyone, I have policy numbers given to me in a spreadsheet of various lengths. We use 7 digit policy numbers here and I need to convert these feed numbers to 7 digit numbers so that I can further break them down into three columns containing the “first 3”, “second 2” and “last 2” of the 7 digit number.

The best solution that I could imagine was to use this rather long if function to get the 7 digits and then use it to produce my three columns. The function just determines the length of the feed number and appends the appropriate amount of zero’s to the front.
Code:
=IF(LEN(A2)=1,"000000"&A2,IF(LEN(A2)=2,"00000"&A2,IF(LEN(A2)=3,"0000"&A2,IF(LEN(A2)=4,"000"&A2,IF(LEN(A2)=5,"00"&A2,IF(LEN(A2)=6,"0"&A2,IF(LEN(A2)=6,"0"&A2,A2)))))))

I can’t simply just format the feed column, because that will not allow me to produce the three columns. The function will work, I was just wondering if anyone has a better solution. Regards, Marc
7 digit policy number.xls
ABCDE
1FeedNo.7DigitsFirst3Middle2Last2
2100000010000001
31200000120000012
412300001230000123
5123400012340001234
61234500123450012345
712345601234560123456
8123456712345671234567
Sheet1
 

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.
Why not just use Format, Custom, to 0000000 rather than the lengthy formula? Then you can split them form there - possbily with Data | Text tio Columns.

Give it a try.
 
Upvote 0
nevillestoke,

Changing the Format only changes the appearance, not the underlying values. Add then taking it to Text to Columns will not change that.

You actually need to convert the data to text with the leading zeroes, like what LTunnicliffe suggests.
 
Upvote 0
jmiskey

thanks for setting me straight on this one :oops: I continue to be amazed at the amount of stuff available on this forum :idea: !

Neville
 
Upvote 0
Thanks for the offerings everyone. I’ve attached what they produce below. The problem I have with the various solutions is that when I go to produce my column to get the first 3 digits of the seven digit policy number I’m not getting the first 3 characters(digits) when referencing the 7 digit solutions.

Phantom, You offer something that looks like it could work, but I could not get it to make the zero’s become leading zero’s. Again Thanks All, Marc

PS. If converting the given feed number to anything will enable a solution I can go with that. It doesn’t have to be a number.
7 digit policy number.xls
ABCDE
1FeedNo.7DigitsFirst3Middle2Last2
2100000010000001
31200000120000012
412300001230000123
5123400012340001234
61234500123450012345
712345601234560123456
8123456712345671234567
9
10LtunnicliffeandMarkW.Offering
111000000110001
12120000012120012
1312300001231230123
14123400012341231234
151234500123451232345
1612345601234561233456
17123456712345671234567
18
19SetiOffering
201000000110001
21120000012120012
2212300001231230123
23123400012341231234
241234500123451232345
2512345601234561233456
26123456712345671234567
Sheet1
 
Upvote 0

Forum statistics

Threads
1,221,709
Messages
6,161,431
Members
451,705
Latest member
Priti_190

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