+ Reply to Thread
Results 1 to 4 of 4

Decimal Number Format in ComboBox

  1. #1
    Drummer361
    Guest

    Decimal Number Format in ComboBox

    Hello,

    I am working on a project where I am defining the content of Combo
    Boxes with the code below from the "UserForm Initialize" command:

    For v = 13 To 16
    ComboBox1.AddItem Worksheets("Worksheet1").Cells(v, 9).Value
    Next v

    This fills the data nicely in the combo boxes.

    However, I am stuck with number decimal formatting. Let's say I want
    all of the numbers in the ComboBox to have 3 decimal places of
    accuracy, even if it lists xx.000. Does anybody have any code ideas to
    work with the current code I have?

    I appreciate any feedback!!


  2. #2
    Paul Black
    Guest

    Re: Decimal Number Format in ComboBox

    Hi Drummer361,

    Try something like :-

    NumberFormat = "0.000"

    Hope this Helps.
    All the Best.
    Paul

    Drummer361 wrote:
    > Hello,
    >
    > I am working on a project where I am defining the content of Combo
    > Boxes with the code below from the "UserForm Initialize" command:
    >
    > For v = 13 To 16
    > ComboBox1.AddItem Worksheets("Worksheet1").Cells(v, 9).Value
    > Next v
    >
    > This fills the data nicely in the combo boxes.
    >
    > However, I am stuck with number decimal formatting. Let's say I want
    > all of the numbers in the ComboBox to have 3 decimal places of
    > accuracy, even if it lists xx.000. Does anybody have any code ideas to
    > work with the current code I have?
    >
    > I appreciate any feedback!!



  3. #3
    Drummer361
    Guest

    Re: Decimal Number Format in ComboBox

    Hi Paul, thanks for the quick response!

    I just got it to partially work! Here is how I implemented the code:

    For v = 13 To 16
    ComboBox1.AddItem Format((Worksheets("Worksheet1").Cells(v,
    9).Value), "0.000")
    Next v

    My issue now is that the initial number that displays before you click
    on the ComboBox drop-down list isn't formatted. I must be overlooking
    something on the UserForm Initialize command? It's formatted in the
    Excel worksheet, and after I select a new value in the drop-down the
    number I choose is formatted fine. Just the value on form load remains
    without any decimal formatting.... any suggestions?

    Thanks!


  4. #4
    Drummer361
    Guest

    Re: Decimal Number Format in ComboBox

    I figured it out!

    Here is the code that runs from a module called in the
    UserForm_Initialize command:

    formUserForm1.ComboBox1.Value = Format(formUserForm1.ComboBox1.Value,
    "#.000")


    Drummer361 wrote:
    > Hi Paul, thanks for the quick response!
    >
    > I just got it to partially work! Here is how I implemented the code:
    >
    > For v = 13 To 16
    > ComboBox1.AddItem Format((Worksheets("Worksheet1").Cells(v,
    > 9).Value), "0.000")
    > Next v
    >
    > My issue now is that the initial number that displays before you click
    > on the ComboBox drop-down list isn't formatted. I must be overlooking
    > something on the UserForm Initialize command? It's formatted in the
    > Excel worksheet, and after I select a new value in the drop-down the
    > number I choose is formatted fine. Just the value on form load remains
    > without any decimal formatting.... any suggestions?
    >
    > Thanks!



+ 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