Trying to close sheets without firing the macros...

johnohio

New Member
Joined
May 12, 2005
Messages
48
Office Version
  1. 2016
Platform
  1. Windows
I am working on a spreadsheet with several tabs & macros. When I close the spreadsheet I want to hide all the tabs except one.

Code:
Sub hidesome()
Application.ScreenUpdating = False

Dim ws As Worksheet
 
    For Each ws In Worksheets
        If ws.Name <> "Main" Then ws.Visible = xlSheetHidden
    Next
Application.ScreenUpdating = True
End Sub

The problem is when I run as it closes the sheets it appears to trigger the macos as it selects the sheets to close them.
I have several sheets that have macros that run when you select a the sheet, so I am assuming that is the issue?

Is there a way to fix that?

Thanks for your help.
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Try

VBA Code:
Sub hidesome()
Application.EnableEvents = False 'Turn off event listening

'...your code

Application.EnableEvents = True
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,223,248
Messages
6,171,021
Members
452,374
Latest member
keccles

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