+ Reply to Thread
Results 1 to 3 of 3

Formatting data in a listbox

  1. #1
    Registered User
    Join Date
    02-10-2011
    Location
    Copenhagen, DK
    MS-Off Ver
    Excel 2007
    Posts
    30

    Formatting data in a listbox

    Hi y'all,

    I am populating a listbox with 5 columns using this code:
    Please Login or Register  to view this content.
    It works fine, however the formatting is ugly. I would like column 1 & 5 to be a date DD-MM-YYYY and column 2-4 to be number with commastyle (x.xxx,xx).

    Is this possible?

    Thanks for your time!!

    Kind regards
    KRAND
    Last edited by KRAND; 05-12-2011 at 04:24 AM.

  2. #2
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Formatting data in a listbox

    I'd guess that you lose your formatting when you put the cell range into a variant variable. Can you do it like this instead?

    Please Login or Register  to view this content.
    Note: this may affect whether your list is dynamically updated as those cells change.
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Registered User
    Join Date
    02-10-2011
    Location
    Copenhagen, DK
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: Formatting data in a listbox

    Hi Dave,

    Thanks for your answer.

    I could not get your code working. But you where right about the formatting being killed by the Variant definition.

    I found a way to "cheat" the code. I formattet all the data to text with a normal funktion: eg. =Text(B2; #.###).

    Doing this I now get formattet data in my ListBox1.

    THank you for your time!

    Kind Regards
    KRAND

+ 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