IRish3538
11-05-2016, 09:07 AM
So I'm making these ad-hoc checkboxes (because activex sucks) but can't seem to get this to fire correctly. If D1 is selected, unselect D2 (that works). but if D2 is selected, uncheck D1 doesn't work. I know it's because when D2 is selected, it makes the target D1 and goes thru the progression again. Just can't figure out how to fix it. Any help would be greatly appreciated! Thanks!
The checkboxes are wingdings. chr(168) = unchecked, chr(254) = checked
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'This is the first part that just checks/unchecks the boxes if they're pressed
If Not Intersect(Range("d1:d2"), Target) Is Nothing Then
Application.EnableEvents = False
Cancel = True
If Target.Value = Chr(254) Then
Target.Value = Chr(168)
Else
Target.Value = Chr(254)
End If
Application.EnableEvents = True
End If
On Error Resume Next
'This is my attempt at trying to uncheck the other thing
Select Case Target
Case Is = Range("d1")
If Target.Value = Chr(254) Then Range("d2:d5").Value = Chr(168)
Case Is = Range("d2")
If Target.Value = Chr(254) Then Range("d1").Value = Chr(168)
End Select
End Sub
The checkboxes are wingdings. chr(168) = unchecked, chr(254) = checked
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'This is the first part that just checks/unchecks the boxes if they're pressed
If Not Intersect(Range("d1:d2"), Target) Is Nothing Then
Application.EnableEvents = False
Cancel = True
If Target.Value = Chr(254) Then
Target.Value = Chr(168)
Else
Target.Value = Chr(254)
End If
Application.EnableEvents = True
End If
On Error Resume Next
'This is my attempt at trying to uncheck the other thing
Select Case Target
Case Is = Range("d1")
If Target.Value = Chr(254) Then Range("d2:d5").Value = Chr(168)
Case Is = Range("d2")
If Target.Value = Chr(254) Then Range("d1").Value = Chr(168)
End Select
End Sub