P
pkeegs
I have the following code in a Macro to refresh an external database query.
Sheets("Client & Staff Data").Select
ActiveSheet.Unprotect Password:="pancake"
ActiveWorkbook.RefreshAll
Range("M3:N3").Select
Selection.AutoFill Destination:=Range("M3:N98"), Type:=xlFillDefault
ActiveSheet.Protect Password:="pancake"
When I test it by stepping through the code using F8 it works perfectly. But
when I activate it with a button, I get two messages that I need to first
unprotect the sheet. Why is it working when tested but not on the button?
Regards
Sheets("Client & Staff Data").Select
ActiveSheet.Unprotect Password:="pancake"
ActiveWorkbook.RefreshAll
Range("M3:N3").Select
Selection.AutoFill Destination:=Range("M3:N98"), Type:=xlFillDefault
ActiveSheet.Protect Password:="pancake"
When I test it by stepping through the code using F8 it works perfectly. But
when I activate it with a button, I get two messages that I need to first
unprotect the sheet. Why is it working when tested but not on the button?
Regards