How to use AutoFilter Macro in Excel

Closed
Report
Posts
3
Registration date
Wednesday September 27, 2017
Status
Member
Last seen
September 28, 2017
-
Complete Macro Newb, so I apologize for my ignorance. I know what the problem is, I am just not sure how to fix it.

I am filtering one spreadsheet (Utilization Report) by a specific Client, Copying all columns and pasting into another workbook (Book 1).
Each Client has its own tab by name in Book 1 and I will repeat the process 47 times until the specific clients are pulled out. The first client works as intended, but my problem is with "Active Window" (its not returning back to the Utilization Report for the filtered data.

I'm just not sure what specific parts of the code to change and how to identify the Utilization Report as the source for filtered data.


Sub CopyClientUtilInNetworkReports()
'
' CopyClientUtilInNetworkReports Macro
' Copy the CLIENT utilization reports to Book1 - run client in network setup first
'


'
Rows("1:1").Select
Selection.AutoFilter
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
Range("B1").Select
ActiveSheet.Range("$A$1:$S$48588").AutoFilter Field:=2, Criteria1:= _
"Client 1"
Columns("A:A").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Windows("Book1").Activate
Sheets("Client 1").Select
Range("A1").Select
ActiveSheet.Paste
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
ActiveSheet.Range("$A$1:$S$48588").AutoFilter Field:=2, Criteria1:= _
"Client 2"
Columns("A:A").Select
Range(Selection, Selection.End(xlToRight)).Select
Application.CutCopyMode = False
Selection.Copy
Application.CutCopyMode = False
Selection.Copy
Windows("Book1").Activate
Sheets("Client 2").Select
Columns("A:A").Select
ActiveSheet.Paste
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 1