alantse2010
New Member
- Joined
- Jun 9, 2018
- Messages
- 34
- Office Version
- 365
- 2019
- 2016
- 2010
- Platform
- Windows
Hi all, I want to use the autofilter for partial match in two columns, it not works for two columns but works for one column.
May I know how to revise the code?
If I use below formula, it works, but i don't know how to convert to VBA code that make it editable as filter formula
Would anyone help?
THank you very much.
May I know how to revise the code?
VBA Code:
Sub Search()
Dim Mws As Worksheet
Dim PR As Worksheet
Dim Rng As Range
Set Mws = ThisWorkbook.Sheets("Data input v2")
Set PR = ThisWorkbook.Sheets("Project Record")
Mws.Range("C19:AW9999").ClearContents
Set Rng = PR.Range("D2:AX" & PR.Cells(PR.Rows.Count, "AX").End(xlUp).Row)
With Rng
'Rng.AutoFilter Field:=4, Criteria1:=Mws.Range("E5").Value
'Rng.AutoFilter Field:=5, Criteria1:=Mws.Range("G5").Value
Rng.AutoFilter Field:=4, Criteria1:="*" & Mws.Range("E5").Value & "*"
Rng.AutoFilter Field:=5, Criteria1:="*" & Mws.Range("G5").Value & "*"
Rng.Offset(1, 0).Resize(.Rows.Count - 1, .Columns.Count - 1).Copy Mws.Range("C19")
Rng.Parent.AutoFilterMode = False
End With
End Sub
If I use below formula, it works, but i don't know how to convert to VBA code that make it editable as filter formula
Excel Formula:
=IFS(I9="Partial Match",FILTER('Project Record'!D3:AX99999,ISNUMBER(SEARCH(E5,'Project Record'!G3:G99999))*ISNUMBER(SEARCH(G5,'Project Record'!H3:H99999)),"No Match Found"))
Would anyone help?
THank you very much.