Home |
Search |
Today's Posts |
|
#1
![]() |
|||
|
|||
![]()
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
![]() |
|||
|
|||
![]()
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
![]() |
|||
|
|||
![]()
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
![]() |
|||
|
|||
![]()
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
![]() |
|||
|
|||
![]()
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
![]() |
|||
|
|||
![]()
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
![]() |
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Nesting Combo Boxes /Returning an Array | Excel Discussion (Misc queries) | |||
MACRO - copy rows based on value in column to another sheet | Excel Discussion (Misc queries) | |||
macro that brings user to cell based on "yes/no" response | Excel Discussion (Misc queries) | |||
Can a macro be made to work based on a formula? | Excel Discussion (Misc queries) | |||
Can a macro be made to work based on a formula? | Excel Discussion (Misc queries) |