+ Reply to Thread
Results 1 to 2 of 2

[SOLVED] zero filled changed to non-zero filled

  1. #1
    JPM
    Guest

    [SOLVED] 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. #2
    Mark Dev
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1