VBA code for refreshing query on protected sheet

karolina1406

Board Regular
Joined
Apr 18, 2016
Messages
110
Office Version
  1. 365
Platform
  1. Windows
hi, can someone help with vba code for refreshing query (called "Query1) on protected with a password "123" sheet called "Summary"?
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
maybe easiest with the macro recorder. is that familiar? unprotect sheet, refresh query, re-protect sheet
start macro recorder with ALT-T-M-R
and finish maybe (may vary by version & I don't know about 365) with pressing rectangle at far LHS of status bar
I don't know the way 365 refers to query table objects either
if you want to refine the recorded code, please post it back to the forum. cheers
 
Upvote 0
maybe easiest with the macro recorder. is that familiar? unprotect sheet, refresh query, re-protect sheet
start macro recorder with ALT-T-M-R
and finish maybe (may vary by version & I don't know about 365) with pressing rectangle at far LHS of status bar
I don't know the way 365 refers to query table objects either
if you want to refine the recorded code, please post it back to the forum. cheers
;) thank you for your help. Recorded macro was actually very easy and it almost worked ;) It updated the query table with all the "added" values however, when any value was removed from the source table - it didn't update Query table with this removal. the code was as below
VBA Code:
 ActiveSheet.Unprotect
 ActiveWorkbook.RefreshAll
 
Upvote 0
That is not expected query behavior. The VBA is not the issue - it has worked: it is something else with the set up.

Suggest you check the source table reference - be sure that when the refresh is done the data source is the modified data and the connection is to that saved version.
(I don't think the SQL could be an issue, but best to check that too. Long shot, and seems unlikely/wrong, but maybe queries in 365 have some setting for deleted data to somehow to not be removed. This would really surprise me.)
 
Upvote 0

Forum statistics

Threads
1,214,792
Messages
6,121,612
Members
449,039
Latest member
Mbone Mathonsi

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