Hi,
I'd like 2 macros to automatically run when opening my excel sheet. At the moment I have to click 2 buttons seperately to enact this.
The first button is
Public Sub EnableOutliningWithProtection_AllSheets()
'PURPOSE: Allow Outline functionality during Protection in all Sheets
'SOURCE: www.TheSpreadsheetGuru.com/the-code-vault
Dim sht As Worksheet
'Loop through each Worksheet in ActiveWorkbook
For Each sht In ActiveWorkbook.Worksheets
'Unprotect Sheet
ActiveSheet.Unprotect ""
'Enable Group Collapse/Expand Capabilities
ActiveSheet.EnableOutlining = True
ActiveSheet.EnableAutoFilter = True
Next sht
End Sub
The second button is
Sub TextBox1_Click()
For a = 4 To 1500
If Worksheets("Salaries").Cells(a, 16).Value = "N" Then
Worksheets("Salaries").Rows(a).Hidden = True
End If
Next
End Sub
If I create the following
Public Sub Workbook_Open()
Call EnableOutliningWithProtection_AllSheets
Call TextBox1_Click
End Sub
Under the ThisWorkbook, it works, but only if the file is opened with the Salaries tab being the first tab that opens. I'd like a different tab to open initially.
With the tab I want to open I get the following error message
'Unable to set the hidden property of the range class'
And if I click debug it highlights the below
Worksheets("Salaries").Rows(a).Hidden = True
Do you know if it is possible for this to work with a different tab opening originally?
Thanks
I'd like 2 macros to automatically run when opening my excel sheet. At the moment I have to click 2 buttons seperately to enact this.
The first button is
Public Sub EnableOutliningWithProtection_AllSheets()
'PURPOSE: Allow Outline functionality during Protection in all Sheets
'SOURCE: www.TheSpreadsheetGuru.com/the-code-vault
Dim sht As Worksheet
'Loop through each Worksheet in ActiveWorkbook
For Each sht In ActiveWorkbook.Worksheets
'Unprotect Sheet
ActiveSheet.Unprotect ""
'Enable Group Collapse/Expand Capabilities
ActiveSheet.EnableOutlining = True
ActiveSheet.EnableAutoFilter = True
Next sht
End Sub
The second button is
Sub TextBox1_Click()
For a = 4 To 1500
If Worksheets("Salaries").Cells(a, 16).Value = "N" Then
Worksheets("Salaries").Rows(a).Hidden = True
End If
Next
End Sub
If I create the following
Public Sub Workbook_Open()
Call EnableOutliningWithProtection_AllSheets
Call TextBox1_Click
End Sub
Under the ThisWorkbook, it works, but only if the file is opened with the Salaries tab being the first tab that opens. I'd like a different tab to open initially.
With the tab I want to open I get the following error message
'Unable to set the hidden property of the range class'
And if I click debug it highlights the below
Worksheets("Salaries").Rows(a).Hidden = True
Do you know if it is possible for this to work with a different tab opening originally?
Thanks