VBA Code to Refresh power Query Table unlock/lock worksheet

Yecart77

New Member
Joined
Nov 8, 2022
Messages
20
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
Platform
  1. Windows
Hi All,

Hopefully and easy one to solve in the hands of experts.

With an unprotected worksheet I have data in Power Query that is presented in a table with a Slicer and a button set up with this macro assigned to refresh the table that works perfectly.

Sub RefreshQuery()

ThisWorkbook.Worksheets("Worksheet Name').ListObjects("Query Name").QueryTable.Refresh

End Sub


But I do want to protect the worksheet and still allow people do not have the protect worksheet password to
  1. Use the Slicer
  2. Be able to click on the button to refresh the table.

How can I modify the above macro to allow people to use the slicer and be able to click on the refresh button and table updates?

Thank you one and all, I appreciate the help.

Cheers,
Tracey
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
By clicking the refresh button, you mean the Macro button you are putting on the sheet, not the actual Data > Refresh All button, correct?
 
Upvote 0
By clicking the refresh button, you mean the Macro button you are putting on the sheet, not the actual Data > Refresh All button, correct?
Yes, I want to put a button above the table to refresh the table.
 
Upvote 0

Forum statistics

Threads
1,223,943
Messages
6,175,546
Members
452,652
Latest member
eduedu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top