Leading Zeros on String

paulkc

Board Regular
Joined
May 18, 2007
Messages
204
Office Version
  1. 365
I have several rather lengthy spreadsheets that have a column of text data. Some cells might have just one number in it such as 4. Then some cells might have something like 1-10. I am trying to import these into Access and sort them based on the first number if there is an array such as the 1-10. I know how to get the leading zeros on the single numbers such as 4 but how would I do that on the 1-10? I would like for my current 1-10 to show up at 001-010 while at the same time 11-15 would show up as 011-015. Or I could settle with only adding the leading zeros on the first part so that it ends up as 001-10 and 011-15.
If possible I would like to be able to (using the same formula) also change a single digit number such as 4 to 004.
All of these cells are formatted as text because a number format will not accept the dash.
Does anyone have any suggestions on how this could be accomplished? Thanks.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
I have several rather lengthy spreadsheets that have a column of text data. Some cells might have just one number in it such as 4. Then some cells might have something like 1-10. I am trying to import these into Access and sort them based on the first number if there is an array such as the 1-10. I know how to get the leading zeros on the single numbers such as 4 but how would I do that on the 1-10? I would like for my current 1-10 to show up at 001-010 while at the same time 11-15 would show up as 011-015. Or I could settle with only adding the leading zeros on the first part so that it ends up as 001-10 and 011-15.
If possible I would like to be able to (using the same formula) also change a single digit number such as 4 to 004.
All of these cells are formatted as text because a number format will not accept the dash.
Does anyone have any suggestions on how this could be accomplished? Thanks.

Hi paulkc:

Following is my convoluted formula approach ...

<html><head><title>Excel Jeanie HTML</title></head><body>
Excel Workbook
ABCD
1****
2*1-10001-010*
3*11-15011-015*
4*4004*
5****
Sheet5


</body></html>
 
Upvote 0
Following on from Yogi's idea...

Excel Workbook
ABCD
1
21-11001-011
311-15011-015
44004
54-4004-004
6123-568123-568
7003-05003-005
80000
90-08000-008
10
Reformat
 
Upvote 0

Forum statistics

Threads
1,215,035
Messages
6,122,791
Members
449,095
Latest member
m_smith_solihull

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