i have this code to serch with combobox and textbox and its good in work for some column i want change it to become search appear all column in range ( a : o )
Dim x, ws As Worksheet, i As Long, j As Long, lastRow As Long
With Me.ListBox1
.Clear
.ColumnCount = 7
.ColumnWidths = "60 pt;150 pt;80 pt;150 pt;100 pt;70 pt;100 pt"
.ColumnHeads = 0
Set ws = Sheets("Ledger")
x = Application.Match(ComboBox1.Value, ws.Rows(1), 0)
If Not IsError(x) Then
lastRow = ws.Cells(Rows.Count, "B").End(xlUp).Row
For i = 1 To lastRow
If TextBox1 <> "" And InStr(ws.Cells(i, x), TextBox1) <> 0 Then
.AddItem
.List(j, 0) = ws.Cells(i, 1)
.List(j, 1) = ws.Cells(i, 3)
.List(j, 2) = ws.Cells(i, 4)
.List(j, 3) = ws.Cells(i, 16)
.List(j, 4) = ws.Cells(i, 17)
.List(j, 5) = ws.Cells(i, 18)
.List(j, 6) = ws.Cells(i, 10)
j = j + 1
End If
Next i
End If
End With
many thanks
Dim x, ws As Worksheet, i As Long, j As Long, lastRow As Long
With Me.ListBox1
.Clear
.ColumnCount = 7
.ColumnWidths = "60 pt;150 pt;80 pt;150 pt;100 pt;70 pt;100 pt"
.ColumnHeads = 0
Set ws = Sheets("Ledger")
x = Application.Match(ComboBox1.Value, ws.Rows(1), 0)
If Not IsError(x) Then
lastRow = ws.Cells(Rows.Count, "B").End(xlUp).Row
For i = 1 To lastRow
If TextBox1 <> "" And InStr(ws.Cells(i, x), TextBox1) <> 0 Then
.AddItem
.List(j, 0) = ws.Cells(i, 1)
.List(j, 1) = ws.Cells(i, 3)
.List(j, 2) = ws.Cells(i, 4)
.List(j, 3) = ws.Cells(i, 16)
.List(j, 4) = ws.Cells(i, 17)
.List(j, 5) = ws.Cells(i, 18)
.List(j, 6) = ws.Cells(i, 10)
j = j + 1
End If
Next i
End If
End With
many thanks