Macro, SaveAs in New Instance of Excel, PasteValues, Close, return to Original Workbook

jacobrcotton

Board Regular
Joined
Jan 28, 2017
Messages
56
Hey Everyone,

I doubt this is a new/unique ask, but I'm having trouble searching for it. I have a workbook/macro that does a series of calls to an SQL server, returning recordsets, and pasting that data into a Workbook. The Workbook then uses that data/recordsets for a bunch of formulas and charts and exhibits.

The ask (to me) is to run this in a batch for multiple clients. Specifically, run the macro, PasteValues, SaveAs (with a specific file name), then run it again for the next client.

The problem I have is that once I Paste Values, the formulas don't exist, and it won't work for the next client.

My proposed solution:
(1) run the macro - Original Workbook
(2) ALT + Save As, which will Save As & open the new save as new instance of Excel - New Workbook
(3) Paste Values - New Workbook
(4) Save the New Workbook
(5) Close the New Workbook
(6) Refocus on the Original Workbook, run next client

Problems I'm having:
(1) I don't know how to ALT+SaveAs in VBA. I can .SaveAs FileName easily, but I can't find out how to ".SaveAsNewWorkbook FileName" (not sure if I'm communicating that correctly or very well)
(2) Is there an easier solution to this problem that my proposed solution above? Am I overthinking this?

Thanks!
 
I'd do the copy/paste values/formatting into a copy worksheet(s) within ThisWorkbook, and copy that sheet(s) to a new workbook, to save for the client.
 
Upvote 0

Forum statistics

Threads
1,226,795
Messages
6,193,046
Members
453,772
Latest member
aastupin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top