VBA to hide sheets when save button is pressed

kylehawkins79

New Member
Joined
May 31, 2019
Messages
7
Is there a VBA or macro that can hide certain sheets when the save button is pressed? Thank you
 

Some videos you may like

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
40,973
Office Version
365
Platform
Windows
How about
Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
   Dim Ws As Worksheet
   
   For Each Ws In Sheets(Array("[COLOR=#ff0000]Sheet1[/COLOR]", "[COLOR=#ff0000]Sheet2[/COLOR]", "[COLOR=#ff0000]Sheet3[/COLOR]"))
      Ws.Visible = xlSheetHidden
   Next Ws
End Sub
Change the names in red to match your sheet names
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
40,973
Office Version
365
Platform
Windows
You're welcome & thanks for the feedback
 

Watch MrExcel Video

Forum statistics

Threads
1,099,607
Messages
5,469,659
Members
406,665
Latest member
priyankape2005

This Week's Hot Topics

Top