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:
 

Some videos you may like

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Watch MrExcel Video

Forum statistics

Threads
1,098,845
Messages
5,465,044
Members
406,409
Latest member
windiestboat

This Week's Hot Topics

Top