Excel VBA - Excel restarts after code closes ActiveWorkbook

2Took

Board Regular
Joined
Jun 13, 2022
Messages
203
Office Version
  1. 365
Platform
  1. Windows
How to avoid Excel restarting after below code is run and only workbook closes:


VBA Code:
ActiveWorkbook.Close SaveChanges:=False
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Try.

Delete your "ActiveWorkbook.Close SaveChanges:=False"
Add the code below.

The code will close this Excel of your vba and any workbooks belong to the Excel without saveing files.
So be careful to use the code.
VBA Code:
Application.DisplayAlerts=False
Application.Quit
 
Upvote 0
Try.

Delete your "ActiveWorkbook.Close SaveChanges:=False"
Add the code below.

The code will close this Excel of your vba and any workbooks belong to the Excel without saveing files.
So be careful to use the code.
VBA Code:
Application.DisplayAlerts=False
Application.Quit
  1. Code I was using closes the Excel along with other open workbooks without saving them.
  2. Code you are suggesting appears to intent to do the same exact thing. And you seem to be describing that as such.

  3. Therefore problem is not solved.

  4. Looking for a code that will close only the workbook that contains that code.
  5. If that was the only open workbook, don't want for Excel to restart after closing.
  6. If there were other open workbooks, don't want for Excel to close, but just close the intended workbook and leave other open workbooks open.

  7. I'm quite sure the right code would be a one liner, nothing complex.
  8. But, maybe somebody knows better.
 
Upvote 0

Forum statistics

Threads
1,213,565
Messages
6,114,337
Members
448,568
Latest member
Honeymonster123

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