zero filled changed to non-zero filled

J

JPM

Hello,

I'm filling a worksheet with a recordset. I need to know how to set the
format of a cell or column . . .
The data is a zip code; it may have a leading zero. How do I retain the zero
when feeding the worksheet? i.e. it is interpreting the data as a number and
stripping the leading zero. I know I can manually set this in Excel. I need
to programmatically set the cell or column to retain the zero.

'Sht = worksheet, rst = recordset.

Sht.Cells(i, i1 + 1) = rst.fields("zip").value

Any help is much appreciated.

JPM
 
M

Mark Dev

JPM,

How about padding the number with leading zero's? Try this:

Sht.Cells(i, i1 + 1) = Right$("00000" & Trim$(rst.Fields("zip").Value), 5)

Regards,
Mark
 

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