+ Reply to Thread
Results 1 to 3 of 3

Format in Combobox / Listbox

Hybrid View

  1. #1
    Forum Contributor CobraLAD's Avatar
    Join Date
    07-23-2007
    Location
    Boksburg, South Africa
    MS-Off Ver
    Office 2019
    Posts
    346

    Format in Combobox / Listbox

    Hi

    I have on a sheet data from column A - E

    000001 | ACC001 | Account Name | 25 Mar 2008 | R 20,560.00


    when I list in a Combobox with 5 columns it display like this

    1 | ACC001 | Account Name | 3/25/2008 | 20560

    Is there a way to display exactly as it is on the sheet. I am using this code

    Dim MainList As Integer
    MainList = Sheet5.Range("A65536").End(xlUp).Row
    UserForm1.ComboBox1.List = Sheet5.Range("A2:E2", "A" & MainList).Value
    I have tried a ListBox as well, same thing
    Last edited by CobraLAD; 03-25-2008 at 11:55 PM.

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    The .Text property of the cells, which returns what is displayed rather than the underlying value, is needed. Unfortunatly, it won't bulk load like .Value, so a loading loop is needed.

    (Mac OS10.5 Excel 2004)

    Dim xArray As Variant
    Dim i As Long, j As Long
    With Sheet5.Range("A2:E2", "A" & Sheet5.Range("A65536").End(xlUp).Row)
        ReDim xRRay(1 To .Rows.Count, 1 To Columns.Count)
        For i = 1 To .Rows.Count
            For j = 1 To .Columns.Count
                xArray(i, j) = .Cells(i, j).Text
            Next j
        Next i
    End With
    
    UserForm1.ListBox1.List = xArray
    UserForm1.Show
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834
    try
    Dim a, i As Long
    Dim MainList As Integer
    MainList = Sheet5.Range("A65536").End(xlUp).Row
    a = Sheet5.Range("A2:E2", "A" & MainList).Value
    For i = 1 To UBound(a,1)
        a(i,1) = Format$(a(i,1),"000000")
        a(i,4) = Format$(a(i,4), "dd mmm yyyy")
        a(i,5) = "R " & Format$(a(i,5),"#,##0.00")
    Next
    UserForm1.ComboBox1.List = a

+ 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