Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default While sheet is protected, allow cmdButton to refresh query.

I have two sections on my sheet. One being a query and the next section for
users to input data. The query is protected and the later can be edited.
However, I would like to allow users to click on an update button which I
have programmed to update the queries from database. When the sheet is
protected, users failed to click on the button eventhough I have uncheck the
lock property.

This is the code for the update button:
Private Sub cmdButton_RefreshMDBF_Click()

Range("MDBF_Query").QueryTable.Refresh BackgroundQuery:=False
Range("Plan_MDBF_Query").QueryTable.Refresh BackgroundQuery:=False
Range("MDBF_Plan").Calculate

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default While sheet is protected, allow cmdButton to refresh query.

Hi M,

Try:
'===========
Private Sub cmdButton_RefreshMDBF_Click()
Dim SH As Worksheet

Set SH = Sheets("Sheet1") '<<==== CHANGE

SH.Unprotrect Password:= "Your password"

'Your query code

SH.Protrect Password:= "Your password"

End Sub
'<<===========


---
Regards,
Norman



"mhng" wrote in message
...
I have two sections on my sheet. One being a query and the next section for
users to input data. The query is protected and the later can be edited.
However, I would like to allow users to click on an update button which I
have programmed to update the queries from database. When the sheet is
protected, users failed to click on the button eventhough I have uncheck
the
lock property.

This is the code for the update button:
Private Sub cmdButton_RefreshMDBF_Click()

Range("MDBF_Query").QueryTable.Refresh BackgroundQuery:=False
Range("Plan_MDBF_Query").QueryTable.Refresh BackgroundQuery:=False
Range("MDBF_Plan").Calculate

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default While sheet is protected, allow cmdButton to refresh query.

Thanks. It worked!

"Norman Jones" wrote:

Hi M,

Try:
'===========
Private Sub cmdButton_RefreshMDBF_Click()
Dim SH As Worksheet

Set SH = Sheets("Sheet1") '<<==== CHANGE

SH.Unprotrect Password:= "Your password"

'Your query code

SH.Protrect Password:= "Your password"

End Sub
'<<===========


---
Regards,
Norman



"mhng" wrote in message
...
I have two sections on my sheet. One being a query and the next section for
users to input data. The query is protected and the later can be edited.
However, I would like to allow users to click on an update button which I
have programmed to update the queries from database. When the sheet is
protected, users failed to click on the button eventhough I have uncheck
the
lock property.

This is the code for the update button:
Private Sub cmdButton_RefreshMDBF_Click()

Range("MDBF_Query").QueryTable.Refresh BackgroundQuery:=False
Range("Plan_MDBF_Query").QueryTable.Refresh BackgroundQuery:=False
Range("MDBF_Plan").Calculate

End Sub




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Refresh Pivot table data in Protected sheet Sumanthkaka Excel Discussion (Misc queries) 3 July 16th 09 05:25 AM
Refresh pivot table on protected sheet richzip Excel Discussion (Misc queries) 3 January 18th 08 08:21 PM
refresh external data on a protected sheet ajf Excel Discussion (Misc queries) 0 March 11th 05 09:01 AM
Refresh Modified Query From Same Sheet Abdul[_6_] Excel Programming 0 November 3rd 04 10:35 AM
Refreshing an external query on a protected sheet gavjs Excel Programming 1 October 21st 03 10:12 PM


All times are GMT +1. The time now is 12:47 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"