Leading zeros with text

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.
 
F

Frank Kabel

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top