Padding a Number

C

Chris

I have a text column of numbers that range from 6 to 9
characters in length. I need to left pad with zeros so
that all of the numbers are 9 characters in length. Can
you tell me the function I should use and possibly provide
an example?

TIA
Chris
 
A

Anon

Chris said:
I have a text column of numbers that range from 6 to 9
characters in length. I need to left pad with zeros so
that all of the numbers are 9 characters in length. Can
you tell me the function I should use and possibly provide
an example?

TIA
Chris

One way:
=RIGHT("000"&A1,9)
 
A

Anon

Quite right. OP said he had a text column. You suggested he try a custom
format. Applying a custom format to a text column will do nothing. It has to
be converted from text first, which you didn't mention.
 
D

Don Guillett

Sub FixRangeValues()
For Each c In Selection
c.Value = Format(c, "00")
Next
End Sub
 
Top