Results 1 to 6 of 6

Listbox not showing all the data needed

Threaded View

  1. #1
    Registered User
    Join Date
    09-27-2019
    Location
    England
    MS-Off Ver
    Office 365
    Posts
    3

    Listbox not showing all the data needed

    Hello,

    I'm currently using a Textbox and a listbox to make a search form for my spreadsheet.
    Currently you can search using any of the data in a row and it'll pull one line to the listbox, but won't show any duplicates with slightly different information etc.

    I need it to show any data matching any of the cells.

    Can anyone help me?

    Private Sub CommandButton2_Click()
    
    Dim i As Long
    Me.listboxsearch.Clear
    
    'Column Headers
    
    Me.listboxsearch.AddItem
    For A = 1 To 5
    Me.listboxsearch.List(0, A - 1) = Sheet1.Cells(1, A)
    Next A
    Me.listboxsearch.Selected(0) = True
    
    'Grabbing information from the columns.
    
    For i = 2 To Sheet1.Range("A1000000").End(xlUp).Offset(1, 0).Row
    For J = 1 To 5
    H = Application.WorksheetFunction.CountIf(Sheet1.Range("A" & 2, "E" & i), Sheet1.Cells(i, J))
    If H = 1 And LCase(Sheet1.Cells(i, J)) = LCase(Me.TextBox1) Or H = 1 And Sheet1.Cells(i, J) = Val(Me.TextBox1) Then
    Me.listboxsearch.AddItem
    For X = 1 To 5
    Me.listboxsearch.List(listboxsearch.ListCount - 1, X - 1) = Sheet1.Cells(i, X)
    Next X
    End If
    Next J
    Next i
    
    
    
    End Sub
    Thanks guys
    Last edited by KH97; 10-01-2019 at 08:46 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Showing search result in listbox
    By Mahmoudelnemr in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-21-2019, 07:45 AM
  2. Listbox showing data searched in a sheet using the given combobox value
    By minominuccio in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 11-21-2017, 10:34 AM
  3. ListBox Is not showing Headers (UserForm)
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 07-30-2017, 08:38 AM
  4. Not showing value time in TextBox and ListBox
    By Seeuw in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 12-14-2013, 06:27 AM
  5. 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
  6. Listbox is showing data from outside the range set?
    By Smurlos in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-21-2010, 08:41 AM
  7. Showing data from specific columns in a listbox
    By Smurlos in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-21-2010, 11:13 AM

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