+ Reply to Thread
Results 1 to 6 of 6

Protected Sheet not refreshing

  1. #1
    Forum Contributor
    Join Date
    01-25-2021
    Location
    Atlanta, Georgia
    MS-Off Ver
    365
    Posts
    144

    Protected Sheet not refreshing

    Can someone tell me why this is not working? I have code that opens another workbook, unprotects it, refresh all, protects it, but allows auto filtering to work.

    Application.ScreenUpdating = False
    Workbooks.Open Path
    Sheet1.UnProtect "password"
    Sheet2.UnProtect "password"
    ActiveWorkbook.RefreshAll
    Sheet1.Protect Password:="password", AllowFiltering:=True
    Sheet1.EnableSelection = xlNoRestrictions
    Sheet2.Protect Password:="password", AllowFiltering:=True
    Sheet2.EnableSelection = xlNoRestrictions
    ActiveWorkbook.Save
    ActiveWindow.Close

    thanks

  2. #2
    Valued Forum Contributor
    Join Date
    01-07-2022
    Location
    Europe
    MS-Off Ver
    Office 365
    Posts
    473

    Re: Protected Sheet not refreshing

    What happens when you try to run it? What isn't working?

    If it's the case that nothing visible is changing, you might just need to re-enable screen updating

    i.e. at the end place the code
    Please Login or Register  to view this content.
    Otherwise, need a further description of the issue and/or sample workbook
    <<< If you have valued anyone's contributions in this thread, please click * to thank them for their efforts

  3. #3
    Valued Forum Contributor
    Join Date
    01-07-2022
    Location
    Europe
    MS-Off Ver
    Office 365
    Posts
    473

    Re: Protected Sheet not refreshing

    another issue could be that Sheet1 and Sheet2 are referring to the workbook that you called the macro from - not the Sheet1 and Sheet 2 in the workbook you have just opened

    not tested, but try the below

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    01-25-2021
    Location
    Atlanta, Georgia
    MS-Off Ver
    365
    Posts
    144

    Re: Protected Sheet not refreshing

    Not sure why the Sheet1/Sheet2 reference was an issue but changed to your solution with added "With" statement and it worked. Thanks AskMeAboutExcel!

  5. #5
    Valued Forum Contributor
    Join Date
    01-07-2022
    Location
    Europe
    MS-Off Ver
    Office 365
    Posts
    473

    Re: Protected Sheet not refreshing

    No problem.

    The issue is that without specifying which workbook to choose Sheet 1 and Sheet 2 from, it was trying to run the code on Sheet 1 and Sheet 2 on the workbook that you called the macro from.
    Even though the new workbook that you open was the active workbook, Excel needs to be told to reference Sheet 1 and Sheet 2 from that workbook instead. The With statement clarifies that.

  6. #6
    Forum Contributor
    Join Date
    01-25-2021
    Location
    Atlanta, Georgia
    MS-Off Ver
    365
    Posts
    144

    Re: Protected Sheet not refreshing

    Makes sense. I went ahead and change all sheet names on the workbook I am calling the macro from jut to avoid any future hiccups.....thanks again.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Refreshing pivot tables in a protected sheet
    By j.s.ingle in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-05-2020, 02:46 PM
  2. Refreshing PivotTable in protected sheet
    By Jayfaas in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 11-14-2017, 11:10 AM
  3. Refreshing PowerQuery Tables on a Protected Sheet
    By boxahoy in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 10-20-2017, 07:26 AM
  4. Refreshing a Pivot is a protected worksheet
    By paulary30 in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 02-12-2013, 01:37 PM
  5. Refreshing radio button to previous state after deselection on a protected sheet
    By alamar in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-11-2013, 10:48 AM
  6. Refreshing a protected worksheet
    By snappytim in forum Excel General
    Replies: 5
    Last Post: 01-07-2013, 06:49 AM
  7. Importing/Refreshing Data from Password-Protected Website
    By daniel3417 in forum Excel General
    Replies: 5
    Last Post: 06-29-2012, 12:46 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1