ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Need a left pad formula method (https://www.excelbanter.com/excel-programming/326886-need-left-pad-formula-method.html)

quartz[_2_]

Need a left pad formula method
 
I am using Windows XP and Office 2003.

I need a formula to left pad some ID numbers that contain both letters and
numbers and can be from three to seven characters in length so that all IDs
have ten characters. This conversion will occur in another column. For
example:

8912 would become 0000008912
42138A would become 000042138A

I tried: =Text(A1, "0000000") and this works great when the ID is all
numbers, but this fails if letters are involved.

OJ[_2_]

Need a left pad formula method
 
Hi,
Assuming the originals are in Column A and you want the padded version
in column B this should work (you may have to format both columns as
text)

=REPT("0",10-LEN(A1))&A1

HTH,
OJ


quartz[_2_]

Need a left pad formula method
 
That works great! Thanks OJ! - and good night.

"OJ" wrote:

Hi,
Assuming the originals are in Column A and you want the padded version
in column B this should work (you may have to format both columns as
text)

=REPT("0",10-LEN(A1))&A1

HTH,
OJ



Tom Ogilvy

Need a left pad formula method
 
(you may have to format both columns as text)

Just to add then:

You don't need to format either column as text. the results will be text
irrespective of formatting.

--
Regards,
Tom Ogilvy


"OJ" wrote in message
oups.com...
Hi,
Assuming the originals are in Column A and you want the padded version
in column B this should work (you may have to format both columns as
text)

=REPT("0",10-LEN(A1))&A1

HTH,
OJ





All times are GMT +1. The time now is 03:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com