Closing secondary files

atf32

Board Regular
Joined
Apr 13, 2011
Messages
157
I am looking for a line of VBA code to use after I execute code to go into a secondary file to make an update and then “save (as new file) and close” the secondary file without having to get the exit message that asks me if I want to save the file. I am currently using the following lines in a “BeforeClose” event. Target lines are stepped through when I close the workbook either from within the secondary file and when I close from the first file. However, it only works when I am closing from within the secondary file. If I am in the first file and then run code to execute the closing of the second file line of code in the “BeforeClose” event steps through accordingly, but does not execute the following lines.

With ThisWorkbook
.SaveAs [NewFileSaveName]
.Close savechanges:=False
End With

Is there a better way of handling this process?:confused:
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Forum statistics

Threads
1,213,536
Messages
6,114,211
Members
448,554
Latest member
Gleisner2

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