VBA: close a workbook and DON'T save changes

istril

Board Regular
Joined
Aug 15, 2008
Messages
109
I have a working macro that opens a workbook, does some stuff, and then closes it. But, when I run the macro, it prompts me as to whether or not I want to save changes. Is there a way I can write into the macro not to save the changes?

Currently the code I'm using to close the workbook is the following:

Windows("MTAP.xls").Activate
ActiveWindow.Close

If you know better code, and also a way to tell it not to save changes, I'd be very appreciative!
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Thanks jindon!

I am encountering one other problem with this macro though, and was wondering if you or someone else could help:

Range("tempchart!A2:F97").Copy
Sheets("Master").Unprotect
Range("Master!A2:F97").Insert Shift:=xlDown
Sheets("Master").Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

Doesn't work. I'm trying to just copy a range of cells onto a protected sheet. When the macro runs, it inserts the specified cells, but not the values I copied along with it. Any idea why?
 
Upvote 0
Because unprotecting worksheet after copy will empty clipboard.
Change the order...
Code:
Sheets("Master").Unprotect
Range("tempchart!A2:F97").Copy
Range("Master!A2:F97").Insert Shift:=xlDown
Sheets("Master").Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
 
Upvote 0

Forum statistics

Threads
1,223,630
Messages
6,173,451
Members
452,514
Latest member
cjkelly15

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