replicate feel of checkbox

R

robnsd

My question is- is there a way to replicate the feel of a checkbox
within an
excel cell where one click on the cell sets the cell to a certain
value , say
"X", and another click on the cell sets it to a different value, say
"" .

I've received direction (below) on how to do this with a single
column, but I need to do it with two noncontiguous columns (column C
and H but not the columns in between)


Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Intersect(Columns("B:B"), Target) Is Nothing Then Exit Sub
If Target.Count > 1 Then Exit Sub
If Target.Value = "" Then
Target.Value = "X"
Else
Target.Value = ""
End If

End Sub

Any help would be appreciated.

Thanks,

Robert
 
G

Guest

If the code you have does what you want but only for a single range then you
can modify it a number of ways, here's a quick one:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Intersect(Columns("B:B"), Target) Is Nothing Then
If Intersect(Columns("D:D"), Target) Is Nothing Then Exit Sub
End If
If Target.Count > 1 Then Exit Sub
If Target.Value = "" Then
Target.Value = "X"
Else
Target.Value = ""
End If

End Sub
 
R

robnsd

If the code you have does what you want but only for a single range then you
can modify it a number of ways, here's a quick one:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Intersect(Columns("B:B"), Target) Is Nothing Then
If Intersect(Columns("D:D"), Target) Is Nothing Then Exit Sub
End If
If Target.Count > 1 Then Exit Sub
If Target.Value = "" Then
Target.Value = "X"
Else
Target.Value = ""
End If

End Sub
--
Cheers,
Shane Devenshire










- Show quoted text -

Thanks for your help. That did the trick.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top