Mark McInerney
Active Member
- Joined
- Apr 4, 2012
- Messages
- 291
- Office Version
- 365
- Platform
- Windows
Hi All,
I am trying to decipher how to run a macro when I have protected all the worksheets on my spreadsheet. I am not an experienced VBA person so appreciate any help on this.
My attempt (which is largely driven by using the 'record macro' option) is as follows:
Sub Split_Shift()
'
' Split_Shift Macro
'
'
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Unprotect Password:="W0UGHREA"
Next ws
Columns("E:O").Select
Selection.EntireColumn.Hidden = True
Columns("D:P").Select
Selection.EntireColumn.Hidden = False
Range("B13").Select
For Each ws In ThisWorkbook.Worksheets
ws.Protect Password:="W0UGHREA"
Next ws
ActiveSheet.Select
End Sub
The problem I have is that I keep ending up on a different worksheet and not the one that I ran the macro from?
Any help appreciate
I am trying to decipher how to run a macro when I have protected all the worksheets on my spreadsheet. I am not an experienced VBA person so appreciate any help on this.
My attempt (which is largely driven by using the 'record macro' option) is as follows:
Sub Split_Shift()
'
' Split_Shift Macro
'
'
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Unprotect Password:="W0UGHREA"
Next ws
Columns("E:O").Select
Selection.EntireColumn.Hidden = True
Columns("D:P").Select
Selection.EntireColumn.Hidden = False
Range("B13").Select
For Each ws In ThisWorkbook.Worksheets
ws.Protect Password:="W0UGHREA"
Next ws
ActiveSheet.Select
End Sub
The problem I have is that I keep ending up on a different worksheet and not the one that I ran the macro from?
Any help appreciate