PDA

View Full Version : [SOLVED:] Multiple Individual Exclusive Checkboxes with data validation Macro (code here)



Schutzhofer
01-16-2023, 02:08 PM
Hi Guys! I need you.: pray2:

I'm trying to introduce Checkboxes into my personal project planning, unfortunately normal Checkboxes tend to bug out (after 300pcs). So I found this article here and I'm trying to convert it into a macro to select the rows I want checks at (continuously if I add new lines). Specifically the last one of the attached file (2nd sheet) that is NOT "Mutually Exclusive" but with data validation. Main vbaexpess address + /kb/getarticle.php?kb_id=879

Unfortunately it does not let me make/rewrite it into a macro like I wanted to and I spent a lot of time trying already. :-(


Please Help

I tried to write a SelectionRng. Or searched for a way to write it into a Macro to select it in the Worksheet.
Example from VBAExpress: 30441



Option Explicit

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

'Limit Target count to 1
If Target.Count > 1 Then Exit Sub
'Isolate Target to a specific range
If Intersect(Target, Range("Ckboxes")) Is Nothing Then Exit Sub
'Set Target font to "marlett"
Target.Font.Name = "marlett"
'Check value of target
If Target.Value <> "a" Then
Target.Value = "a" 'Sets target Value = "a"
Target.Interior.ColorIndex = 44
Cancel = True
Exit Sub
End If
If Target.Value = "a" Then
Target.ClearContents 'Sets target Value = ""
Target.Interior.ColorIndex = 0
Cancel = True
Exit Sub
End If
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)

'Limit Target count to 1
If Target.Count > 1 Then Exit Sub
'Isolate Target to a specific range
If Intersect(Target, Range("Ckboxes")) Is Nothing Then Exit Sub
'Select a specific subset of the range "Ckboxes"
Select Case Target.Address
Case Else
'Populate the cell to the right of Target with its status
If Target.Value = "a" Then
Target.Offset(0, 6) = "Checked"
Else:
Target.Offset(0, 6).Value = "Not Checked"
End If
End Select
End Sub

Artik
01-16-2023, 08:49 PM
In Sheet1 you have three examples of marking states. Choose what you want.

Artik

Schutzhofer
01-17-2023, 12:37 AM
Hi Artik!
Yes, that is precisely what I need!

This looks amazing!
Thank you very much! :-)


In Sheet1 you have three examples of marking states. Choose what you want.

Artik

Result Example:
30445