index and search problems

Adablablas

New Member
Joined
Mar 15, 2023
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hi, I have been trying to find a solution to this for several days now and still can't figure it out. I need the correct cell to be selected when searching and selecting a value from the listbox, not just with the value of the listbox index.
This is the code of the click event
VBA Code:
Private Sub ListBox1_Click()
    Dim fila As Long, i As Long, ULTFILA As Long
    
    fila = Me.ListBox1.ListIndex
    
    ULTFILA = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row
    For i = 1 To ULTFILA
        Cells(fila + 1, 1).Activate
        fila = fila + 1
    Next i
End Sub
And this a part of the search code
VBA Code:
For x = 2 To Sheets(2).Range("B" & Rows.Count).End(xlUp).Row
        If InStr(1, UCase(Sheets(2).Range("C" & x).Value), UCase(Me.TextBox1.Value)) > 0 Then
            coinci = True
            ReDim Preserve list(15, y)
            list(1, y) = Sheets(2).Range("b" & x).Text
            list(2, y) = Sheets(2).Range("c" & x).Text
            y = y + 1
        End If
    Next
    If coinci = True Then
        Me.ListBox1.RowSource = ""
        Me.ListBox1.list = Application.Transpose(list)
    Else
        Me.ListBox1.RowSource = ""
    End If
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Forum statistics

Threads
1,223,246
Messages
6,170,988
Members
452,373
Latest member
TimReeks

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top