Adablablas
New Member
- Joined
- Mar 15, 2023
- Messages
- 3
- Office Version
- 365
- Platform
- 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
And this a part of the search code
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
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