Hello all,
I have a pricing worksheet I have built that works exactly the way we want it to. The first sheet "Job Cost Totals" is our primary sheet where our pricing is completed and our totals are shown. The second sheet "Service Estimate" helps calculate a number of things that add into the "Job Cost Totals" sheet. (For example, putting in prices and quantities in "Service Estimate" B29:C39 and clicking the 'Quick Transfer to Job Cost' button at the top of the sheet will take those numbers and bring them to the "Job Cost Totals" sheet.
These two sheets are built to work together. We also often create different options for pricing (which would require these sheets to be duplicated). While I know we could just create multiple workbooks, there is a desire to be able to have all of our options in this one workbook. The problem I am facing is that when duplicating the sheets, because of how the code is written to go back and forth between these specific sheets, I don't know how to make all the buttons and macros update for the duplicated sheets.
EX. Right now my sheets are hardcoded as JobCost and ServiceEstimate. Multiple parts of the VBA transfer information between these two sheets. When creating a duplicate sheet, the hardcode changes to JobCost1 for the new sheet, but all the VBA for the buttons are still linked to JobCost (original sheet).
There is currently a button on the "Job Cost Totals" sheet at the top right called 'Create New Option Sheet'. What I would like to be able to do is have our team be able to click that button, have a duplicate of "Job Cost Totals" created and a duplicate of "Service Estimate" created, then have all of the macros involved work between those two duplicated sheets separately from the original two. Additionally, then be able to create multiple sets of duplicates that all work in their pairing of JobCost/ServiceEstimate without affecting the others or having to manually update VBA. This is a sheet I am building for people who do not know excel well, so it's important for me to do the most backend work where they can just click a button and have all of this happen automatically.
Example of Final Product: "Job Cost Totals" and "Service Estimate" - "Option #1" and "Estimate Option 1" - "Option #2" and "Estimate Option 2". Each of those pairs of sheets having the macros, buttons, and all coding work between them, updated and ready to go automatically when the 'Create Option Sheet' button is pushed.
A few things I've thought of:
- I wondered about using "ActiveSheet" instead of naming the sheets in the code, but I wouldn't know how to make that work when two specific sheets need to work together.
- Ideally, our team would want the ability to be able to change the tabbed sheet names (not the hardcode) without it affecting the VBA. If this is not possible, then protecting the sheet names from being changed would be an option.
- I thought about creating subs with the potential copied sheet names ahead of time, even if not in use, but then I don't know how to re-assign the buttons in the duplicated sheets to the new subs automatically.
I've attached the workbook here. Let me know if you have any questions - would love to solve this conundrum!
Bookmarks