Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Edit Spreadsheet when a button is clicked

Status
Not open for further replies.

jmeckley

Programmer
Jul 15, 2002
5,269
US
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 trick is the
Code:
 UserInterfaceOnly
parameter. See my post in thread707-588794 for an example.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top