Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
zero filled changed to non-zero filled
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
zero filled changed to non-zero filled
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 "JPM" wrote in message ... 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Need Sum of 2 columns if one is filled? | Excel Discussion (Misc queries) | |||
Filled cells dont appear as filled | Excel Discussion (Misc queries) | |||
Last filled row | Excel Discussion (Misc queries) | |||
Color filled in auto but from where | Excel Worksheet Functions | |||
Last Filled Column | Excel Programming |