PDA

View Full Version : Writing a Macro for Checkbox Form



jimbokentuck
09-18-2008, 03:56 PM
Hi, I'm using Excel 2003. If I use a forms checkbox, and the user will check it or not. If the user doesn't check the box then input is required in the next cell. However if the user checks the box I don't want them to put anything in the next cell. Is there a way to accomplish this?

mikerickson
09-18-2008, 05:33 PM
Change the formating of all the cells on the sheet to UnLocked.
Then Assign the checkbox to this macro.
Sub CheckBox1_Click()
With ActiveSheet
.Unprotect
.Range("A1").Locked = CBool(.Shapes(Application.Caller).ControlFormat.Value And 1)
.Protect
End With
End Sub

jimbokentuck
09-18-2008, 06:23 PM
Thanks!

mikerickson
09-18-2008, 07:35 PM
A non-VB approach would be to link the check-box to a cell (B1 in this example). And then put Validation on the cell that you want it to control, with the formula =NOT($B$1)