Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi all! I have set up a "fun" office quiz sheet, with a number of questions
with specific one and two-word answers. I have protected the sheet so it is only possible to enter text into the specific "Answer" Cells. A cell next to these answers tells the user whether the answer is correct or incorrect. However, I would like to be able to limit the number of incorrect answers a user can enter into one cell (for example - 3 attempts), and if they enter an incorrect answer 3 times the cell becomes locked with their last attempt. Is it possible to do this? Any help anyone could give would be much appreciated!!! |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sounds like a lot of work, but you could use the change event to react to an
entry: for a start, See Chip Pearson's page on events http://www.cpearson.com/excel/events.htm -- Rgards, Tom Ogilvy "TBD" wrote in message ... Hi all! I have set up a "fun" office quiz sheet, with a number of questions with specific one and two-word answers. I have protected the sheet so it is only possible to enter text into the specific "Answer" Cells. A cell next to these answers tells the user whether the answer is correct or incorrect. However, I would like to be able to limit the number of incorrect answers a user can enter into one cell (for example - 3 attempts), and if they enter an incorrect answer 3 times the cell becomes locked with their last attempt. Is it possible to do this? Any help anyone could give would be much appreciated!!! |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Tom,
Thanks for your help on this, it's much appreciated! Having read Chip Pearsons "Event Procedure", I have tried to simplify this problem. Basically now, I would like to lock a cell if the value entered into that very same cell does not equal a value I have specified in the Event code. For example, I have done the following very basic code: Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Target.Address = "$B$8" Then Aplication.EnableEvents = False If Target.Value = "Jane Doe" Then Range("B8").Locked = False Else Range("B8").Locked = True End If Apllication.EnableEvents = True End If End Sub However, I am consisitently getting de-bug messages. Is the problem with the code the fact the Target.Address and cell to lock are one and the same (B8)? Thanks again! TBD "Tom Ogilvy" wrote: Sounds like a lot of work, but you could use the change event to react to an entry: for a start, See Chip Pearson's page on events http://www.cpearson.com/excel/events.htm -- Rgards, Tom Ogilvy "TBD" wrote in message ... Hi all! I have set up a "fun" office quiz sheet, with a number of questions with specific one and two-word answers. I have protected the sheet so it is only possible to enter text into the specific "Answer" Cells. A cell next to these answers tells the user whether the answer is correct or incorrect. However, I would like to be able to limit the number of incorrect answers a user can enter into one cell (for example - 3 attempts), and if they enter an incorrect answer 3 times the cell becomes locked with their last attempt. Is it possible to do this? Any help anyone could give would be much appreciated!!! |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
To unlock/lock a cell, you must remove the sheet protection, unlock/lock the
cell, then readd the sheet protection Private Sub Worksheet_Change(ByVal Target As Excel.Range) On Error goto ErrHandler If Target.Address = "$B$8" Then Application.EnableEvents = False ' application mispelled (corrected) Me.Unprotect If Target.Value = "Jane Doe" Then Range("B8").Locked = False Else Range("B8").Locked = True End If Me.Protect 'Apllication.EnableEvents = True ' application mispelled End If ErrHandler Application.EnableEvents if err.Number < 0 then msgbox "There has been an error" End if End Sub If you have used a password, you would need to supply it as well Me.Unprotect Password:="Mary" Me.Protect Password:="Mary" -- Regards, Tom Ogilvy "TBD" wrote in message ... Hi Tom, Thanks for your help on this, it's much appreciated! Having read Chip Pearsons "Event Procedure", I have tried to simplify this problem. Basically now, I would like to lock a cell if the value entered into that very same cell does not equal a value I have specified in the Event code. For example, I have done the following very basic code: Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Target.Address = "$B$8" Then Aplication.EnableEvents = False If Target.Value = "Jane Doe" Then Range("B8").Locked = False Else Range("B8").Locked = True End If Apllication.EnableEvents = True End If End Sub However, I am consisitently getting de-bug messages. Is the problem with the code the fact the Target.Address and cell to lock are one and the same (B8)? Thanks again! TBD "Tom Ogilvy" wrote: Sounds like a lot of work, but you could use the change event to react to an entry: for a start, See Chip Pearson's page on events http://www.cpearson.com/excel/events.htm -- Rgards, Tom Ogilvy "TBD" wrote in message ... Hi all! I have set up a "fun" office quiz sheet, with a number of questions with specific one and two-word answers. I have protected the sheet so it is only possible to enter text into the specific "Answer" Cells. A cell next to these answers tells the user whether the answer is correct or incorrect. However, I would like to be able to limit the number of incorrect answers a user can enter into one cell (for example - 3 attempts), and if they enter an incorrect answer 3 times the cell becomes locked with their last attempt. Is it possible to do this? Any help anyone could give would be much appreciated!!! |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The label ErrHandler should have a colon
ErrHandler: rather than just ErrHandler Private Sub Worksheet_Change(ByVal Target As Excel.Range) On Error goto ErrHandler If Target.Address = "$B$8" Then Application.EnableEvents = False ' application mispelled (corrected) Me.Unprotect If Target.Value = "Jane Doe" Then Range("B8").Locked = False Else Range("B8").Locked = True End If Me.Protect 'Apllication.EnableEvents = True ' application mispelled End If ErrHandler: Application.EnableEvents if err.Number < 0 then msgbox "There has been an error" End if End Sub "Tom Ogilvy" wrote in message ... To unlock/lock a cell, you must remove the sheet protection, unlock/lock the cell, then readd the sheet protection Private Sub Worksheet_Change(ByVal Target As Excel.Range) On Error goto ErrHandler If Target.Address = "$B$8" Then Application.EnableEvents = False ' application mispelled (corrected) Me.Unprotect If Target.Value = "Jane Doe" Then Range("B8").Locked = False Else Range("B8").Locked = True End If Me.Protect 'Apllication.EnableEvents = True ' application mispelled End If ErrHandler Application.EnableEvents if err.Number < 0 then msgbox "There has been an error" End if End Sub If you have used a password, you would need to supply it as well Me.Unprotect Password:="Mary" Me.Protect Password:="Mary" -- Regards, Tom Ogilvy "TBD" wrote in message ... Hi Tom, Thanks for your help on this, it's much appreciated! Having read Chip Pearsons "Event Procedure", I have tried to simplify this problem. Basically now, I would like to lock a cell if the value entered into that very same cell does not equal a value I have specified in the Event code. For example, I have done the following very basic code: Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Target.Address = "$B$8" Then Aplication.EnableEvents = False If Target.Value = "Jane Doe" Then Range("B8").Locked = False Else Range("B8").Locked = True End If Apllication.EnableEvents = True End If End Sub However, I am consisitently getting de-bug messages. Is the problem with the code the fact the Target.Address and cell to lock are one and the same (B8)? Thanks again! TBD "Tom Ogilvy" wrote: Sounds like a lot of work, but you could use the change event to react to an entry: for a start, See Chip Pearson's page on events http://www.cpearson.com/excel/events.htm -- Rgards, Tom Ogilvy "TBD" wrote in message ... Hi all! I have set up a "fun" office quiz sheet, with a number of questions with specific one and two-word answers. I have protected the sheet so it is only possible to enter text into the specific "Answer" Cells. A cell next to these answers tells the user whether the answer is correct or incorrect. However, I would like to be able to limit the number of incorrect answers a user can enter into one cell (for example - 3 attempts), and if they enter an incorrect answer 3 times the cell becomes locked with their last attempt. Is it possible to do this? Any help anyone could give would be much appreciated!!! |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Tom, that is working an absolute treat now!!! (Though I must remember
to double-check spelling). I'm now attempting to alter the code so that I can apply it to numerous Cell references on the one worksheet, if that is indeed possible! Thanks for your help! "Tom Ogilvy" wrote: The label ErrHandler should have a colon ErrHandler: rather than just ErrHandler Private Sub Worksheet_Change(ByVal Target As Excel.Range) On Error goto ErrHandler If Target.Address = "$B$8" Then Application.EnableEvents = False ' application mispelled (corrected) Me.Unprotect If Target.Value = "Jane Doe" Then Range("B8").Locked = False Else Range("B8").Locked = True End If Me.Protect 'Apllication.EnableEvents = True ' application mispelled End If ErrHandler: Application.EnableEvents if err.Number < 0 then msgbox "There has been an error" End if End Sub "Tom Ogilvy" wrote in message ... To unlock/lock a cell, you must remove the sheet protection, unlock/lock the cell, then readd the sheet protection Private Sub Worksheet_Change(ByVal Target As Excel.Range) On Error goto ErrHandler If Target.Address = "$B$8" Then Application.EnableEvents = False ' application mispelled (corrected) Me.Unprotect If Target.Value = "Jane Doe" Then Range("B8").Locked = False Else Range("B8").Locked = True End If Me.Protect 'Apllication.EnableEvents = True ' application mispelled End If ErrHandler Application.EnableEvents if err.Number < 0 then msgbox "There has been an error" End if End Sub If you have used a password, you would need to supply it as well Me.Unprotect Password:="Mary" Me.Protect Password:="Mary" -- Regards, Tom Ogilvy "TBD" wrote in message ... Hi Tom, Thanks for your help on this, it's much appreciated! Having read Chip Pearsons "Event Procedure", I have tried to simplify this problem. Basically now, I would like to lock a cell if the value entered into that very same cell does not equal a value I have specified in the Event code. For example, I have done the following very basic code: Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Target.Address = "$B$8" Then Aplication.EnableEvents = False If Target.Value = "Jane Doe" Then Range("B8").Locked = False Else Range("B8").Locked = True End If Apllication.EnableEvents = True End If End Sub However, I am consisitently getting de-bug messages. Is the problem with the code the fact the Target.Address and cell to lock are one and the same (B8)? Thanks again! TBD "Tom Ogilvy" wrote: Sounds like a lot of work, but you could use the change event to react to an entry: for a start, See Chip Pearson's page on events http://www.cpearson.com/excel/events.htm -- Rgards, Tom Ogilvy "TBD" wrote in message ... Hi all! I have set up a "fun" office quiz sheet, with a number of questions with specific one and two-word answers. I have protected the sheet so it is only possible to enter text into the specific "Answer" Cells. A cell next to these answers tells the user whether the answer is correct or incorrect. However, I would like to be able to limit the number of incorrect answers a user can enter into one cell (for example - 3 attempts), and if they enter an incorrect answer 3 times the cell becomes locked with their last attempt. Is it possible to do this? Any help anyone could give would be much appreciated!!! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Quiz Sheet | Excel Worksheet Functions | |||
Is there a limit to the number of rows in a excel spread sheet ? | Excel Discussion (Misc queries) | |||
IF command, limit to number of entries? | Excel Worksheet Functions | |||
limit column entries | Excel Discussion (Misc queries) | |||
How to limit the Number of rows in Excel sheet | Excel Programming |