lindseyschwab
New Member
- Joined
- Sep 29, 2023
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
- MacOS
Hi, I have the below macro written. However, when it runs through it ends on the last tab of my workbook and not on the worksheet I ran the macro on. Is there a way to add in what worksheet to come back to once the macro runs?
Macro:
UnprotectRefreshAll()
Dim ws As Worksheet
On Error Resume Next
For Each ws In ActiveWorkbook.Worksheets
ws.Unprotect Password:="mypassword"
Next ws
ActiveWorkbook.RefreshAll
For Each ws In ActiveWorkbook.Worksheets
ws.Protect Password:="mypassword", _
AllowUsingPivotTables:=True
Next
End Sub
Macro:
UnprotectRefreshAll()
Dim ws As Worksheet
On Error Resume Next
For Each ws In ActiveWorkbook.Worksheets
ws.Unprotect Password:="mypassword"
Next ws
ActiveWorkbook.RefreshAll
For Each ws In ActiveWorkbook.Worksheets
ws.Protect Password:="mypassword", _
AllowUsingPivotTables:=True
Next
End Sub