PDA

View Full Version : Solved: Change the state of cell by clicking on it



kisinana
09-24-2008, 01:26 PM
I am curious if there is a way to have the state of a cell change just by clicking on it. (i.e. change from a false state to a true state)
I know that I can change it by entering a value but was looking for a way that by selecting the cell it would display a check mark or remove it just by clicking on it.

CreganTur
09-24-2008, 01:40 PM
If you're wanting to add in a checkbox, you can do that via the CheckBox tool on the Forms toolbar.

Bob Phillips
09-24-2008, 02:27 PM
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Const WS_RANGE As String = "H1:H10" '<=== change to suit

On Error GoTo err_handler
Application.EnableEvents = False
If Not Application.Intersect(Target, Range(WS_RANGE)) Is Nothing Then
With Target
.Font.Name = "Marlett"
Select Case .Value
Case "": .Value = "a"
Case "a": .Value = ""
End Select
.Offset(0, 1).Select
End With
End If
err_handler:
Application.EnableEvents = True
End Sub


This is worksheet event code, which means that it needs to be
placed in the appropriate worksheet code module, not a standard
code module. To do this, right-click on the sheet tab, select
the View Code option from the menu, and paste the code in.

kisinana
09-25-2008, 10:31 AM
Thanks for the replies.