I have a spread sheet in Excel. This sheet is used to tally votes from a poll we took.
The sheet has Column A as the objects being voted on and Row 1 as the attributes of each object. Nothing fancy.
I have 2 buttons on the sheet: Tally and Undo. Tally will add 1 to the active cell, and Undo will subtract 1 in case of a mistake. Currently the workbook is unprotected so the user potentially could enter any value they wanted in the cell, or delete a cell's value by mistake.
How could I password protect the workbook? And then when the user clicks the buttons have the code unprotect it, do the calculation and protect it again. In theory, only unlocking it when the user clicks the button, and locking it again, before they can change anything.
here is my code so far:[tt]
Private Sub cmdAddOne_Click() 'Tally
On Error Resume Next
ActiveCell = ActiveCell + 1
End Sub
Private Sub cmdMinusOne_Click() 'Undo
On Error Resume Next
If ActiveCell > 0 Then
ActiveCell = ActiveCell - 1
End If
If ActiveCell = 0 Then
ActiveCell = ""
End If
End Sub[/tt]
thanks for the advice
Jason Meckley
Database Analyst
WITF
The sheet has Column A as the objects being voted on and Row 1 as the attributes of each object. Nothing fancy.
I have 2 buttons on the sheet: Tally and Undo. Tally will add 1 to the active cell, and Undo will subtract 1 in case of a mistake. Currently the workbook is unprotected so the user potentially could enter any value they wanted in the cell, or delete a cell's value by mistake.
How could I password protect the workbook? And then when the user clicks the buttons have the code unprotect it, do the calculation and protect it again. In theory, only unlocking it when the user clicks the button, and locking it again, before they can change anything.
here is my code so far:[tt]
Private Sub cmdAddOne_Click() 'Tally
On Error Resume Next
ActiveCell = ActiveCell + 1
End Sub
Private Sub cmdMinusOne_Click() 'Undo
On Error Resume Next
If ActiveCell > 0 Then
ActiveCell = ActiveCell - 1
End If
If ActiveCell = 0 Then
ActiveCell = ""
End If
End Sub[/tt]
thanks for the advice
Jason Meckley
Database Analyst
WITF