Hi, I'd like to open a file but then apply a filter to the data in a tab (let's say Sheet1) then type in certain criteria in the filter in column D, after which I'd like the Sub to import the data displayed when the filter is applied.
I've got a Sub which enables me to select a file then import data from that file without applying any filters.
Buut is there a way to modify this so that it applies a filter to row 4 then allows a user to search for a word eg 'Gold' in the filter in column D, after which it copies all the data that appears on the page when that word is applied in the filter?
This is the Sub I have, so far:
I've got a Sub which enables me to select a file then import data from that file without applying any filters.
Buut is there a way to modify this so that it applies a filter to row 4 then allows a user to search for a word eg 'Gold' in the filter in column D, after which it copies all the data that appears on the page when that word is applied in the filter?
This is the Sub I have, so far:
VBA Code:
Sub ImportTest12()
Dim fd As FileDialog
Dim filewaschosen As Boolean
Dim Report As Workbook
Dim iWB As Workbook
Set Report = ActiveWorkbook
Set fd = Application.FileDialog(msoFileDialogOpen)
fd.Filters.Clear
'fd.Filters.Add "xlsx files", "*.xlsx"
fd.Filters.Add "Custom Excel Files", "*.xlsx, *.xlsm, *.xls"
fd.AllowMultiSelect = False
fd.InitialFileName = Environ("UserProfile") & "\Downloads\"
'filewaschosen = fd.Show
fd.Execute
If fd.Show <> -1 Then
MsgBox "You didn't select a file?"
Exit Sub
End If
fd.Execute
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Range("A2:G" & lastrow).Copy
Report.Activate
ACV.Visible = True
ACV.Activate
Range("A2:G" & lastrow).PasteSpecial
End Sub