Consulting

Results 1 to 2 of 2

Thread: Solved: Listbox Index - Number format

  1. #1
    VBAX Regular
    Joined
    Aug 2009
    Posts
    69
    Location

    Solved: Listbox Index - Number format

    Hi

    I have a userform with a listbox that lists all the values of two columns.
    I am using the following code:

    [vba]
    Dim Rng As Range
    Set Rng = Range(Sheets("Auxiliar").Range("A1"), Sheets("Auxiliar").Range("A" & rows.Count).End(xlUp)).Resize(, 5)

    With ListBox1
    .ColumnCount = 2
    .ColumnWidths = "50,30"
    .List = Application.Index(Rng, Evaluate("row(" & Rng.Address & ") "), Array(1, 5))
    End With
    [/vba]

    It turns out that when for example cell A1 = 0.83333333(3) I need that only appear in the listbox 0.83 and if for example cell A1 = 0.8354643 then 0.84 appear in the listbox.

    How can I do this?

    Thanks in advance

    Miguel

  2. #2
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Try:
    [VBA].List = Application.Round(Application.Index(Rng, Evaluate("row(" & Rng.Address(0, 0, , -1) & ") "), Array(1, 5)), 2)[/VBA]

Posting Permissions

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