Only closing active sheet Code Mod

alexdurc09

New Member
Joined
Sep 21, 2018
Messages
17
Hello,
I have the below code which is attached to a button on aspreadsheet. Its function is to close the spreadsheet down and also savechanges. However, when the button is clicked, it closes down all open spread sheetswhich is no good if my colleagues are working other spread sheets too. Is thereany way so that when clicked, it just shuts down the active spreadsheet and notany other open spread sheets?
TIA,
Alex

Private Sub SaveClose_Click()
ThisWorkbook.allowed = True
Application.Quit
ThisWorkbook.Save
End Sub
 
Last edited:

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.
You can't shut down only one worksheet but you can hide it so it's not visible.
 
Upvote 0
So to clarify, there isn't any VBA code which will close down the sheet that the button is on and were the vba is written and leave all other sheets open?
 
Upvote 0
You can't close down the sheet, you can only hide it from view.
Code:
ActiveSheet.Visible = False
 
Upvote 0
If you just want to save & close the workbook containing the code try
Code:
Private Sub SaveClose_Click()
ThisWorkbook.Close True
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,650
Messages
6,120,734
Members
448,987
Latest member
marion_davis

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