Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
wongard
 
Posts: n/a
Default Macro to automate page protection based on combo box reply

I have a workbook that consists of 13 worksheets. 1st worksheet is an
instructions page. the remaining 12 worksheets correspond to each month of a
calendar year. Each monthly worksheet is protected to prevent entry by users
in certain cells. whilst allowing them to complete the return by filling in
information in given cells.

At the end of the page is a combo box where they select either yes or no to
whether the worksheet is complete. This in turn refers back to the
instruction page updating that the particular worksheet is complete on the
instruction page.

What I am trying to do is a macro, that when the combo box is selected as
yes, automates to protect the entire worksheet regardless of whether a cell
is locked/unlocked, so that the information cannot be changed by the user
without the entering of a password.

Any ideas?
thanks
  #2   Report Post  
Rowan
 
Posts: n/a
Default

If you are using a combobox from the control toolbox then maybe like this:

Private Sub ComboBox1_Change()
If Me.ComboBox1.Value = "Yes" Then
Me.Unprotect Password:="yourpassword"
Cells.Locked = True
Me.Protect Password:="yourpassword"
End If
End Sub

Hope this helps
Rowan

wongard wrote:
I have a workbook that consists of 13 worksheets. 1st worksheet is an
instructions page. the remaining 12 worksheets correspond to each month of a
calendar year. Each monthly worksheet is protected to prevent entry by users
in certain cells. whilst allowing them to complete the return by filling in
information in given cells.

At the end of the page is a combo box where they select either yes or no to
whether the worksheet is complete. This in turn refers back to the
instruction page updating that the particular worksheet is complete on the
instruction page.

What I am trying to do is a macro, that when the combo box is selected as
yes, automates to protect the entire worksheet regardless of whether a cell
is locked/unlocked, so that the information cannot be changed by the user
without the entering of a password.

Any ideas?
thanks

  #3   Report Post  
wongard
 
Posts: n/a
Default

Rowan thanks for that, that actually looks pretty good. Quick question not
being a guru in code, but will this protect all cells or only those that are
locked, I will need to protect unlocked cells also.
Thanks
Peter

"Rowan" wrote:

If you are using a combobox from the control toolbox then maybe like this:

Private Sub ComboBox1_Change()
If Me.ComboBox1.Value = "Yes" Then
Me.Unprotect Password:="yourpassword"
Cells.Locked = True
Me.Protect Password:="yourpassword"
End If
End Sub

Hope this helps
Rowan

wongard wrote:
I have a workbook that consists of 13 worksheets. 1st worksheet is an
instructions page. the remaining 12 worksheets correspond to each month of a
calendar year. Each monthly worksheet is protected to prevent entry by users
in certain cells. whilst allowing them to complete the return by filling in
information in given cells.

At the end of the page is a combo box where they select either yes or no to
whether the worksheet is complete. This in turn refers back to the
instruction page updating that the particular worksheet is complete on the
instruction page.

What I am trying to do is a macro, that when the combo box is selected as
yes, automates to protect the entire worksheet regardless of whether a cell
is locked/unlocked, so that the information cannot be changed by the user
without the entering of a password.

Any ideas?
thanks


  #4   Report Post  
Dave Peterson
 
Posts: n/a
Default

Cells.Locked = true

Will lock all the cells (no matter if they were locked or unlocked when the
macro started).



wongard wrote:

Rowan thanks for that, that actually looks pretty good. Quick question not
being a guru in code, but will this protect all cells or only those that are
locked, I will need to protect unlocked cells also.
Thanks
Peter

"Rowan" wrote:

If you are using a combobox from the control toolbox then maybe like this:

Private Sub ComboBox1_Change()
If Me.ComboBox1.Value = "Yes" Then
Me.Unprotect Password:="yourpassword"
Cells.Locked = True
Me.Protect Password:="yourpassword"
End If
End Sub

Hope this helps
Rowan

wongard wrote:
I have a workbook that consists of 13 worksheets. 1st worksheet is an
instructions page. the remaining 12 worksheets correspond to each month of a
calendar year. Each monthly worksheet is protected to prevent entry by users
in certain cells. whilst allowing them to complete the return by filling in
information in given cells.

At the end of the page is a combo box where they select either yes or no to
whether the worksheet is complete. This in turn refers back to the
instruction page updating that the particular worksheet is complete on the
instruction page.

What I am trying to do is a macro, that when the combo box is selected as
yes, automates to protect the entire worksheet regardless of whether a cell
is locked/unlocked, so that the information cannot be changed by the user
without the entering of a password.

Any ideas?
thanks



--

Dave Peterson
  #5   Report Post  
wongard
 
Posts: n/a
Default

Thanks for that Dave, hopefully one last query to solve this issue. Have
entered the VB code as previously mentioned by Rowan. When I run the macro
though, VB editor wants to debug for an improper use of Me. Any suggestions
how to rectify this?

"Dave Peterson" wrote:

Cells.Locked = true

Will lock all the cells (no matter if they were locked or unlocked when the
macro started).



wongard wrote:

Rowan thanks for that, that actually looks pretty good. Quick question not
being a guru in code, but will this protect all cells or only those that are
locked, I will need to protect unlocked cells also.
Thanks
Peter

"Rowan" wrote:

If you are using a combobox from the control toolbox then maybe like this:

Private Sub ComboBox1_Change()
If Me.ComboBox1.Value = "Yes" Then
Me.Unprotect Password:="yourpassword"
Cells.Locked = True
Me.Protect Password:="yourpassword"
End If
End Sub

Hope this helps
Rowan

wongard wrote:
I have a workbook that consists of 13 worksheets. 1st worksheet is an
instructions page. the remaining 12 worksheets correspond to each month of a
calendar year. Each monthly worksheet is protected to prevent entry by users
in certain cells. whilst allowing them to complete the return by filling in
information in given cells.

At the end of the page is a combo box where they select either yes or no to
whether the worksheet is complete. This in turn refers back to the
instruction page updating that the particular worksheet is complete on the
instruction page.

What I am trying to do is a macro, that when the combo box is selected as
yes, automates to protect the entire worksheet regardless of whether a cell
is locked/unlocked, so that the information cannot be changed by the user
without the entering of a password.

Any ideas?
thanks


--

Dave Peterson



  #6   Report Post  
Dave Peterson
 
Posts: n/a
Default

Rowan wrote the code for use with a Combobox from the control toolbox toolbar
placed on the worksheet.

The code goes behind that worksheet--not in a general module.

If you didn't use that combobox (and don't want to change to it), what did you
use?

wongard wrote:

Thanks for that Dave, hopefully one last query to solve this issue. Have
entered the VB code as previously mentioned by Rowan. When I run the macro
though, VB editor wants to debug for an improper use of Me. Any suggestions
how to rectify this?

"Dave Peterson" wrote:

Cells.Locked = true

Will lock all the cells (no matter if they were locked or unlocked when the
macro started).



wongard wrote:

Rowan thanks for that, that actually looks pretty good. Quick question not
being a guru in code, but will this protect all cells or only those that are
locked, I will need to protect unlocked cells also.
Thanks
Peter

"Rowan" wrote:

If you are using a combobox from the control toolbox then maybe like this:

Private Sub ComboBox1_Change()
If Me.ComboBox1.Value = "Yes" Then
Me.Unprotect Password:="yourpassword"
Cells.Locked = True
Me.Protect Password:="yourpassword"
End If
End Sub

Hope this helps
Rowan

wongard wrote:
I have a workbook that consists of 13 worksheets. 1st worksheet is an
instructions page. the remaining 12 worksheets correspond to each month of a
calendar year. Each monthly worksheet is protected to prevent entry by users
in certain cells. whilst allowing them to complete the return by filling in
information in given cells.

At the end of the page is a combo box where they select either yes or no to
whether the worksheet is complete. This in turn refers back to the
instruction page updating that the particular worksheet is complete on the
instruction page.

What I am trying to do is a macro, that when the combo box is selected as
yes, automates to protect the entire worksheet regardless of whether a cell
is locked/unlocked, so that the information cannot be changed by the user
without the entering of a password.

Any ideas?
thanks


--

Dave Peterson


--

Dave Peterson
  #7   Report Post  
Rowan
 
Posts: n/a
Default

Hi

The code assumes that the combobox is from the controls toolbox and must
be pasted into the sheets code module not a standard module. Right click
the sheet tab, select View Code and paste the event in there.

Regards
Rowan

wongard wrote:
Thanks for that Dave, hopefully one last query to solve this issue. Have
entered the VB code as previously mentioned by Rowan. When I run the macro
though, VB editor wants to debug for an improper use of Me. Any suggestions
how to rectify this?

"Dave Peterson" wrote:


Cells.Locked = true

Will lock all the cells (no matter if they were locked or unlocked when the
macro started).



wongard wrote:

Rowan thanks for that, that actually looks pretty good. Quick question not
being a guru in code, but will this protect all cells or only those that are
locked, I will need to protect unlocked cells also.
Thanks
Peter

"Rowan" wrote:


If you are using a combobox from the control toolbox then maybe like this:

Private Sub ComboBox1_Change()
If Me.ComboBox1.Value = "Yes" Then
Me.Unprotect Password:="yourpassword"
Cells.Locked = True
Me.Protect Password:="yourpassword"
End If
End Sub

Hope this helps
Rowan

wongard wrote:

I have a workbook that consists of 13 worksheets. 1st worksheet is an
instructions page. the remaining 12 worksheets correspond to each month of a
calendar year. Each monthly worksheet is protected to prevent entry by users
in certain cells. whilst allowing them to complete the return by filling in
information in given cells.

At the end of the page is a combo box where they select either yes or no to
whether the worksheet is complete. This in turn refers back to the
instruction page updating that the particular worksheet is complete on the
instruction page.

What I am trying to do is a macro, that when the combo box is selected as
yes, automates to protect the entire worksheet regardless of whether a cell
is locked/unlocked, so that the information cannot be changed by the user
without the entering of a password.

Any ideas?
thanks

--

Dave Peterson

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
Nesting Combo Boxes /Returning an Array ELMONDO SNITHER Excel Discussion (Misc queries) 1 June 30th 05 01:15 AM
MACRO - copy rows based on value in column to another sheet Michael A Excel Discussion (Misc queries) 1 March 5th 05 02:15 AM
macro that brings user to cell based on "yes/no" response lennyx2 Excel Discussion (Misc queries) 2 February 9th 05 02:47 PM
Can a macro be made to work based on a formula? lonnied Excel Discussion (Misc queries) 2 January 26th 05 04:00 AM
Can a macro be made to work based on a formula? lonnied Excel Discussion (Misc queries) 0 January 26th 05 02:59 AM


All times are GMT +1. The time now is 07:01 PM.

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

About Us

"It's about Microsoft Excel"