Hello there, I want to assign keyboard shortcuts to save me time showing toolbars/unlocking worksheets and hiding toolbars/locking worksheets. I've created a VBA macro module called "Tools" and within in, two subs. It's not working at the moment and I think in part it's because I need to combine the code, but not sure exactly how to do this whilst ensuring it works.
For example, are "Sheet" and "Worksheet" considered the same thing by Excel VBA?
Thanks for your help.
For example, are "Sheet" and "Worksheet" considered the same thing by Excel VBA?
VBA Code:
Sub ProtectHide()
Dim Sht As Sheet
For Each Sht In ActiveWorkbook.Sheets
' ActiveSheet.Protect "YourPassword"
ActiveSheet.Protect
Next Sht
Dim wsSheet As Worksheet
Application.ScreenUpdating = False
For Each wsSheet In ThisWorkbook.Worksheets
If Not wsSheet.Name = "Blank" Then
wsSheet.Activate
With ActiveWindow
.DisplayFormulas = True
.DisplayGridlines = False
.DisplayHeadings = False
.DisplayStatusBar = False
.CommandBars("Full Screen").Visible = True
.CommandBars("Worksheet Menu Bar").Enabled = False
.CommandBars("Standard").Visible = False
.CommandBars("Formatting").Visible = False
End With
End If
Next wsSheet
Application.ScreenUpdating = True
End Sub
Sub UnprotectShow()
Dim Sht As Sheet
For Each Sht In ActiveWorkbook.Sheets
' ActiveSheet.Protect "YourPassword"
ActiveSheet.Unprotect
Next Sht
Dim wsSheet As Worksheet
Application.ScreenUpdating = False
For Each wsSheet In ThisWorkbook.Worksheets
If Not wsSheet.Name = "Blank" Then
wsSheet.Activate
With ActiveWindow
.DisplayFormulas = True
.DisplayGridlines = False
.DisplayHeadings = True
.DisplayStatusBar = True
.CommandBars("Full Screen").Visible = True
.CommandBars("Worksheet Menu Bar").Enabled = True
.CommandBars("Standard").Visible = True
.CommandBars("Formatting").Visible = True
End With
End If
Next wsSheet
Application.ScreenUpdating = True
End Sub
Thanks for your help.