Share via

Refresh two specific protected worksheets.

Anonymous
2022-09-12T03:50:03+00:00

This does work. However, I don't need every single worksheet unprotected then protected. The only two worksheets I need to unprotect are "Inbound" and "Data Records".
Thank you,

VBA Code:Private Sub CmdRefresh_click() Call Reset Dim ws As Worksheet On Error Resume Next For Each ws In ActiveWorkbook.Worksheets ws.Unprotect Password:="mozzer" Next ws ActiveWorkbook.RefreshAll For Each ws In ActiveWorkbook.Worksheets ws.Protect Password:="mozzer", _ AllowUsingPivotTables:=True Next ws

End Sub
Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Andreas Killer 144.1K Reputation points Volunteer Moderator
2022-09-12T03:53:54+00:00

Private Sub CmdRefresh_click()
Dim ws As Worksheet
Dim Items, Item

Items = Array("Inbound", "Data Records")

For Each Item In Items
Set ws = Worksheets(Item)
ws.Unprotect Password:="mozzer"
Next

Call Reset
ActiveWorkbook.RefreshAll

For Each Item In Items
Set ws = Worksheets(Item)
ws.Protect Password:="mozzer", AllowUsingPivotTables:=True
Next
End Sub

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Andreas Killer 144.1K Reputation points Volunteer Moderator
    2022-09-12T07:11:39+00:00

    I just don't understand why the user form thinks I'm skipping the date block. So frustrating. I'm still working on it.

    Place breakpoints in each sub in your form, run the form and you can see where and when it stops. Debug the code and you'll what's going on behind the scene.

    Andreas.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2022-09-12T04:43:44+00:00

    I think that works, it does so far, thank you so much for "Everything". I'm still having problems with the other part of the refresh button. I know you given me tips, but I'm struggling, it's not from stupidity. I just don't understand why the user form thinks I'm skipping the date block. So frustrating. I'm still working on it.

    Was this answer helpful?

    0 comments No comments