VBA Filter in External Workbook

dannyok90

Board Regular
Joined
Aug 30, 2016
Messages
115
Hi all,

Im trying to use the following code to open a workbook filter sheet 2 by
column b with "5124" and
column C with "Job numer:" "Parent Job:" "Project Director:" "Client:" "Totals for Job"
Then paste the result in the original active workbook.
I havent got as far as the copying and pasting yet but i guess that will be relatively straight forward?
Any help is greatly appreciated :)
Thanks Dan
Code:
Sub tests()
Dim wbk As Workbook
Set wbk = Workbooks.Open("T:\V-Task\V0000+\200+\V0297\Shared\report.xlsx")
'manipulate the data in the workbook anyway you want, e.g. '
'Variables Declacaration
    Dim Criteria_Val(100) As String
    Dim iRow As Integer
 
    'Loop Thru the List and Create Filter Criteria Array
    iRow = 0
    While Sheets(2).Cells(iRow + 1, 1) <> ""
        Criteria_Val(iRow) = Sheets(2).Cells(iRow + 1, 1)
        iRow = iRow + 1
    Wend
 
    'Multiple Criteria List is Created. Pass it as parameter to Filter
    Sheets(2).Range("B1:B1000000").AutoFilter Field:=1, Criteria1:=Criteria_Val, Operator:=xlFilterValues

'copying and pasting code
Call wbk.Close(False)
End Sub
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,223,889
Messages
6,175,223
Members
452,620
Latest member
dsubash

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top