Hello! I've got a long VBA I'm working on that requires me to take a few worksheets from a saved workbook (Quote Tool) and copy them over to a new workbook. By default, the new workbook is "Book 2," but I'm wondering if there is a way for me to get around this for instances where a person might be doing a few copies and ends up having "Book 3," "Book 4," etc. Here's what I have so far:
Sheets(Array("Account List", "Title List", "Title List Export")).Copy
Sheets("Account List").Select
Application.CutCopyMode = False
Workbooks("Book2").Connections.Add2 _
"WorksheetConnection_Account List!A1:B", "", _
"WORKSHEET;[Book2]Account List", "Account List!A1:B", 7, True, False
If it's helpful, ultimately what I'm trying to do is take the "Account List" sheet and make a pivot table on the "Title List Export" sheet (adding the data to the Data Model), then taking the "Title List" sheet and making a pivot table underneath on the first pivot table on the "Title List Export" sheet (also adding the data to the Data Model).
Thanks in advance!
Sheets(Array("Account List", "Title List", "Title List Export")).Copy
Sheets("Account List").Select
Application.CutCopyMode = False
Workbooks("Book2").Connections.Add2 _
"WorksheetConnection_Account List!A1:B", "", _
"WORKSHEET;[Book2]Account List", "Account List!A1:B", 7, True, False
If it's helpful, ultimately what I'm trying to do is take the "Account List" sheet and make a pivot table on the "Title List Export" sheet (adding the data to the Data Model), then taking the "Title List" sheet and making a pivot table underneath on the first pivot table on the "Title List Export" sheet (also adding the data to the Data Model).
Thanks in advance!