+ Reply to Thread
Results 1 to 5 of 5

ListBox.List(ListBox.ListCount -1, 10) PROBLEM

  1. #1
    Registered User
    Join Date
    02-07-2024
    Location
    USA
    MS-Off Ver
    Excel - Microsoft 365
    Posts
    3

    Lightbulb ListBox.List(ListBox.ListCount -1, 10) PROBLEM

    Hi guys!

    I'd appreciate your help with the following concern.

    I'm trying to complete a ListBox content; however I'm struggling with a simple detail that I don't know how to deal with.

    I noticed that the second part of the list content doesn't accept two digits. Here is the code below. (The problem runs from the "ListCount - 1, 10" and so on)

    last_row = Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).row

    For row_l = 3 To last_row

    If UCase(Cells(row_l, 4).Value) Like "*" & UCase(Me.TBsearch_bid.Value) & "*" Or UCase(Cells(row_l, 3).Value) Like "*" & UCase(Me.TBsearch_bid.Value) & "*" Or UCase(Cells(row_l, 5).Value) Like "*" & UCase(Me.TBsearch_bid.Value) & "*" Then

    Me.ListBox1.AddItem Cells(row_l, 1)

    Me.ListBox1.List(ListBox1.ListCount - 1, 0) = Cells(row_l, 1)
    Me.ListBox1.List(ListBox1.ListCount - 1, 1) = Cells(row_l, 2)
    Me.ListBox1.List(ListBox1.ListCount - 1, 2) = Cells(row_l, 3)
    Me.ListBox1.List(ListBox1.ListCount - 1, 3) = Cells(row_l, 4)
    Me.ListBox1.List(ListBox1.ListCount - 1, 4) = Cells(row_l, 5)
    Me.ListBox1.List(ListBox1.ListCount - 1, 5) = Cells(row_l, 6)
    Me.ListBox1.List(ListBox1.ListCount - 1, 6) = Cells(row_l, 7)
    Me.ListBox1.List(ListBox1.ListCount - 1, 7) = Cells(row_l, 8)
    Me.ListBox1.List(ListBox1.ListCount - 1, 8) = Cells(row_l, 9)
    Me.ListBox1.List(ListBox1.ListCount - 1, 9) = Cells(row_l, 10)
    Me.ListBox1.List(ListBox1.ListCount - 1, 10) = Cells(row_l, 11) <-
    Me.ListBox1.List(ListBox1.ListCount - 1, 11) = Cells(row_l, 12)
    Me.ListBox1.List(ListBox1.ListCount - 1, 12) = Cells(row_l, 13)
    Me.ListBox1.List(ListBox1.ListCount - 1, 13) = Cells(row_l, 14)
    Me.ListBox1.List(ListBox1.ListCount - 1, 14) = Cells(row_l, 15)
    Me.ListBox1.List(ListBox1.ListCount - 1, 15) = Cells(row_l, 16)
    Me.ListBox1.List(ListBox1.ListCount - 1, 16) = Cells(row_l, 17)

    End If

    Next row_l

    Thanks in advance guys!

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,308

    Re: ListBox.List(ListBox.ListCount -1, 10) PROBLEM

    You can only use 10 columns if you use AddItem to populate the listbox. You need to either use a range and the RowSource property or use an array assigned to the List/Column property if you need more columns.
    Last edited by romperstomper; 02-07-2024 at 01:03 PM.
    Anyone who confuses correlation and causation ends up dead.

  3. #3
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,308

    Re: ListBox.List(ListBox.ListCount -1, 10) PROBLEM

    Untested but something like this for example:

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    02-07-2024
    Location
    USA
    MS-Off Ver
    Excel - Microsoft 365
    Posts
    3

    Re: ListBox.List(ListBox.ListCount -1, 10) PROBLEM

    Thanks! I'll try with RowSource or the other options.

  5. #5
    Registered User
    Join Date
    02-07-2024
    Location
    USA
    MS-Off Ver
    Excel - Microsoft 365
    Posts
    3

    Re: ListBox.List(ListBox.ListCount -1, 10) PROBLEM

    Thank you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] listbox to listbox data transfering problem
    By rukman in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-13-2017, 07:26 PM
  2. Listbox.listcount property - application defined or object defined error
    By JulyMoon in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-02-2015, 04:30 PM
  3. Listbox LISTCOUNT propery problem
    By Skitzee in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-20-2014, 09:56 AM
  4. [SOLVED] How do I populate a listbox with a list excluding values found in another listbox?
    By Hokiefan00 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-27-2014, 01:47 PM
  5. Incorrect ListCount value in ListBox
    By BLLMRC in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-19-2013, 01:03 PM
  6. Listbox to Listbox, no duplicates & submitting same UserForm data for each Listbox entry.
    By jamieswift1977 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-18-2012, 12:18 PM
  7. dynamic listbox -- manually change .ListCount property
    By naznorb in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-14-2012, 10:42 AM

Tags for this Thread

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