Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JPM JPM is offline
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Sum of 2 columns if one is filled? TKGerdie Excel Discussion (Misc queries) 4 May 22nd 08 12:30 AM
Filled cells dont appear as filled SMILLS Excel Discussion (Misc queries) 6 October 18th 07 05:28 PM
Last filled row Alberto Pinto Excel Discussion (Misc queries) 5 May 18th 06 11:28 AM
Color filled in auto but from where Cindi Excel Worksheet Functions 3 March 3rd 06 01:31 PM
Last Filled Column GregR Excel Programming 2 November 18th 05 10:47 PM


All times are GMT +1. The time now is 05:53 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"