Hi,
How could I change the code so that it searches the value from cell F2 instead of the value written in the input box.
Any help would be appreciated.
How could I change the code so that it searches the value from cell F2 instead of the value written in the input box.
Code:
Sub Extract_Data()
'Variables used by the macro
Dim FilterCriteria
Dim CurrentFileName As String
Dim NewFileName As String
'Get the current file's name
CurrentFileName = ActiveWorkbook.Name
'Select the first 10 columns and first 100 rows
'(note you can change this to meet your requirements)
On Error Resume Next
ActiveSheet.AutoFilterMode = False
On Error GoTo 0
'Apply Autofilter
Range("F10:I10").AutoFilter
'Get the filter's criteria from the user
FilterCriteria = InputBox("Enter Code")
If FilterCriteria = "" Then Exit Sub
FilterCriteria = Replace(FilterCriteria, "*", "")
FilterCriteria = "*" & FilterCriteria & "*"
'Filter the data based on the user's input
'NOTE - this filter is on column A (field:=1), to change
'to a different column you need to change the field number
Range("F10:I10").AutoFilter field:=1, Criteria1:=FilterCriteria
'Select the visible cells (the filtered data)
End Sub
Any help would be appreciated.