auto.pilot
Well-known Member
- Joined
- Sep 27, 2007
- Messages
- 734
- Office Version
- 365
- Platform
- Windows
I have the following bit of code which is part of a larger project. Near the top, I have identified TheClient as a single cell reference. Within the code, a workbook is opened, then filtered by TheClient in column A. Thereafter, the headers and filtered range are copied and then pasted to the destination workbook. This all works as expected.
However, I would like to now change the code so that TheClient is many Clients, up to 300. How can I do this?
Thanks in advance for all help.
j
However, I would like to now change the code so that TheClient is many Clients, up to 300. How can I do this?
Code:
Dim DestBook As Workbook
Dim TheClient As Long
Dim Last_A As Long
Set DestBook = ActiveWorkbook
TheClient = Range("A1").Value ' <<< instead of one client, I would like to make this many clients (up to 300).
Set SourceBook = Workbooks.Open(Filename:="\\blablabla.SourceBook.xlsx")
Last_A = Range("A" & Rows.Count).End(xlUp).Row
ActiveSheet.Range("A1:IL" & Last_A).AutoFilter Field:=1, Criteria1:=TheClient ''' <<< same here, I'd like to filter the list for many Clients, not just one
Range("A1:IL" & Last_A).Copy
DestBook.Activate
Set PasteDest = Range("A6")
PasteDest.Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
SourceBook.Close False
Thanks in advance for all help.
j