Hello all
A fellow member very kindly provided me with this code to complete a search from a worksheet named "Result" in cell "A6" and search the data from the worksheet called "Data" from column 15
I want to try and expand on this and be able to search more than one column at the same time
"A6" searches column 15
"B6" searches column 3
"C6" searches column 12
If any of the search cells are blank then ignore
"A6" = "" then don't search with this cell value so you would end up with searching on "B6" and "C6"
If "B6 and C6 was blank then you would only search on "A6"
I hope this makes sense and is possible
A fellow member very kindly provided me with this code to complete a search from a worksheet named "Result" in cell "A6" and search the data from the worksheet called "Data" from column 15
I want to try and expand on this and be able to search more than one column at the same time
"A6" searches column 15
"B6" searches column 3
"C6" searches column 12
If any of the search cells are blank then ignore
"A6" = "" then don't search with this cell value so you would end up with searching on "B6" and "C6"
If "B6 and C6 was blank then you would only search on "A6"
I hope this makes sense and is possible
Code:
[LEFT][COLOR=#333333][FONT=monospace]Sub Filter_Me_Please()
'Modified 10/21/2018 1:10:18 PM EDT
Application.ScreenUpdating = False
Dim lastrow As Long
Dim c As Long
Dim s As Variant
Sheets("Data").Activate
c = 15 ' Column Number Modify this to your need
s = Sheets("Result").Range("A6").Value 'Search Value Modify to your need
lastrow = Cells(Rows.Count, c).End(xlUp).Row
With ActiveSheet.Cells(1, c).Resize(lastrow)
.AutoFilter 1, s
counter = .Columns(c).SpecialCells(xlCellTypeVisible).Count
If counter > 1 Then
.Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible).EntireRow.Copy Sheets("Result").Cells(10, "A")
Else
MsgBox "No values found"
End If
.AutoFilter
End With
Application.ScreenUpdating = True
End Sub[/FONT][/COLOR][/LEFT]