Private Sub Workbook_Open() - MACRO HELP!

bluepenink

Well-known Member
Joined
Dec 21, 2010
Messages
585
Hello

Can someone assist me with the logic in my macro below, having trouble intregrating both the macros, pls and thx you!

Code:
Private Sub Workbook_Open()
For c = 1 To Sheets.Count
               With Worksheets(c)
        .Protect Password:="analyst", userinterfaceonly:=True
        .EnableOutlining = True
    End With
Next c
End Sub
Private Sub Workbook_Open()
Application.ScreenUpdating = False
Dim ws As Worksheet
For c = 1 To Sheets.Count
               With Worksheets(c)
        .Protect Password:="analyst", userinterfaceonly:=True
        .EnableOutlining = True
    End With
Next c
' Worksheets().Visible = True
For Each ws In ThisWorkbook.Worksheets
  If ws.Name <> "Enabling Macros" Then
    ws.Visible = True
  End If
Next ws
Worksheets("Calculations").Visible = False

End Sub
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hello

Can someone assist me with the logic in my macro below, having trouble intregrating both the macros, pls and thx you!

Code:
Private Sub Workbook_Open()
For c = 1 To Sheets.Count
               With Worksheets(c)
        .Protect Password:="analyst", userinterfaceonly:=True
        .EnableOutlining = True
    End With
Next c
End Sub
Private Sub Workbook_Open()
Application.ScreenUpdating = False
Dim ws As Worksheet
For c = 1 To Sheets.Count
               With Worksheets(c)
        .Protect Password:="analyst", userinterfaceonly:=True
        .EnableOutlining = True
    End With
Next c
' Worksheets().Visible = True
For Each ws In ThisWorkbook.Worksheets
  If ws.Name <> "Enabling Macros" Then
    ws.Visible = True
  End If
Next ws
Worksheets("Calculations").Visible = False

End Sub

Maybe, something like this?

Code:
Private Sub Workbook_Open()
Application.ScreenUpdating = False
Dim ws As Worksheet

For Each ws In ThisWorkbook.Worksheets

    ws.Protect Password:="analyst", userinterfaceonly:=True
    ws.EnableOutlining = True

  If ws.Name <> "Enabling Macros" Then ws.Visible = True
  If ws.Name = "Enabling Macros" Or ws.Name = "Calculations" Then ws.Visible = False

Next ws

Application.ScreenUpdating = True

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,591
Messages
6,179,768
Members
452,940
Latest member
rootytrip

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