Vonsteiner
New Member
- Joined
- Apr 14, 2014
- Messages
- 45
- Office Version
- 365
- Platform
- Windows
Hey there,
I have seen other posts about copying a worksheet from one workbook to another, but I can't seem to get the syntax correct. Let me explain what I am doing first. My workbook ("Master Invoice List") has two sheets to begin with: Sheet 1 ("Summary") and Sheet 2 ("Master"). "Master" has data from A:CR with a list of companies I need to invoice in E -- each company may have 1-100+ invoices. Once I have all the data in the Mater worksheet input, I create a new worksheet for each company with all their rows and data. Now the "Master Invoice List" has the original 2 sheets plus a sheet for each company ("Company Name") in the list from E of "Master". I have a macro already written to input the necessary formulas into each "Company Name". I then export all the "Company Name" worksheets into a file on a network drive. This is where I am running into my issue. I need some code to copy "Summary" into each "Company Name" files at the beginning of the "Company Name.xlsx" workbook. I can't seem to get the syntax correct to pull "Summary" into the new workbook. The name of the "Company Name.xlsx" file will not always be the same. Any help on this would be greatly appreciated. Thank you. This is the code I tried last:
This works but with the changing "Company Name.xlsx" it wouldn't really work. I have tried other various versions of the above, but since I deleted them to use this last one I don't really remember what they were.
I have seen other posts about copying a worksheet from one workbook to another, but I can't seem to get the syntax correct. Let me explain what I am doing first. My workbook ("Master Invoice List") has two sheets to begin with: Sheet 1 ("Summary") and Sheet 2 ("Master"). "Master" has data from A:CR with a list of companies I need to invoice in E -- each company may have 1-100+ invoices. Once I have all the data in the Mater worksheet input, I create a new worksheet for each company with all their rows and data. Now the "Master Invoice List" has the original 2 sheets plus a sheet for each company ("Company Name") in the list from E of "Master". I have a macro already written to input the necessary formulas into each "Company Name". I then export all the "Company Name" worksheets into a file on a network drive. This is where I am running into my issue. I need some code to copy "Summary" into each "Company Name" files at the beginning of the "Company Name.xlsx" workbook. I can't seem to get the syntax correct to pull "Summary" into the new workbook. The name of the "Company Name.xlsx" file will not always be the same. Any help on this would be greatly appreciated. Thank you. This is the code I tried last:
VBA Code:
Windows("Master Invoice List.xlsm").Activate
sheets("Summary").Select
sheets("Summary").Copy Before:=Workbooks("Company Name.xlsx").sheets(1)
This works but with the changing "Company Name.xlsx" it wouldn't really work. I have tried other various versions of the above, but since I deleted them to use this last one I don't really remember what they were.