Leading zeros with text

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I need to figure out how to format my text to include a set character length
for each field in a column. Additionally, if the text does not meet the
maximum length for the field, then I need leading zeros to make up the
difference beteen the number of characters in the text and the maximum
allowed for the field.

i.e. if I have a name such as Gray in the field and the field needs to be
exactly 13 characters then I need it to be 000000000Gray.
 
Hi
AFAIK this is not possible with formats. You either need a helper cell
or VBA (an event procedure). For a formula solutuion with a helper cell
use
=IF(LEN(A1)<13,REPT("0",13-LEN(A1))&A1),A1)
 
Back
Top