VBA code close file without saving

jpar1983

New Member
Joined
Aug 11, 2012
Messages
25
I have basically three files that I'm working with to copy account data and everything is working fine, I just want to change one tiny thing, because I'm just lazy and don't want to click an extra time with the mouse :). Anyway, I have one Inventory Log (file #1) file that I start with. I run a macro that opens a Secondary Log (file #2) and transfers some information off of each sheet in the Inventory Log to corresponding sheets within the Secondary Log. Then each sheet in the Secondary Log is copied to its own file (file #3) and saved with a name and date (surprisingly easy to do, I was amazed!). Each of these final files is then closed. Because they have already been saved I guess Excel doesn't prompt for a save. Finally I also want to close the Secondary Log (file #2) file that I have without saving it. The Inventory Log (file #1) will stay open. So far the only code I have is:

Activewindow.Close

My usual go-to is to record a macro, do what I want, and the just copy and paste the code with and necessary modifications. In this case, Excel did not pick up on my "No" click in the save prompt, so no code. Anybody have any ideas? Thanks!

Jeremy
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Welcome to the Board!

To close a workbook without saving you can use:

ActiveWorkbook.Close False

Conversely, changing False to True would save it.

HTH,
 
Upvote 0

Forum statistics

Threads
1,215,745
Messages
6,126,634
Members
449,324
Latest member
AmirMalik

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