PDA

View Full Version : Disable a Checkbox with VBA depending on linked cell



janeyjamjar
07-17-2009, 01:55 AM
Hi,

I need to be able to disable checkboxes from within VBA code. ie the code searches through data, and if a certain condition is true I want the check box disabled completely in that row.

Any ideas? It seems stupidly easy but I haven't figured it out.

Thanks

Aussiebear
07-17-2009, 02:45 AM
Without knowing what the condition is that you want to be true its a bit difficult to be precise but this may give you an idea


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If LCase("A1").Value = "Your Value" Then
CheckBox1.Enabled = False
Else
Checkbox1.Enabled = True
End if
End Sub

Bob Phillips
07-17-2009, 03:15 AM
I would think it should be something like


Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$H$1" Then

CheckBox1.Enabled = Target.value = "value"
End If
End Sub