• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Continuation "Allow Only One Checkbox True"

BillyRay

New Member
Hi,

vietm supplied this code that I added for "Status" columns. It isn't only allowing one checkbox true in the other columns. What am I doing wrong?

>>> use code - tags <<<
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    With Target
        ay = .Row
        ax = .Column
    End With
    With ActiveSheet
        If ay > 7 And .Cells(ay, 10) <> Empty Then
            Select Case ax
                Case 7 To 9
                    .Range("G" & ay & ":I" & ay) = False
                    .Cells(ay, ax) = True
            End Select
        End If
    End With
    With Target
        by = .Row
        bx = .Column
    End With
    With ActiveSheet
        If by > 11 And .Cells(by, 14) <> Empty Then
            Select Case bx
                Case 11 To 13
                    .Range("K" & by & ":M" & by) = False
                    .Cells(by, bx) = True
            End Select
        End If
    End With
End Sub
 

Attachments

  • Tasks V2.xlsb
    542.3 KB · Views: 1
Last edited by a moderator:

BillyRay

Do You mean that there should be possible ONE TRUE per row?
... but You've added there (in code) something else.

I guessed Your needs ...
... it could do this way too.
There could be as many those TRUE/FALSE per row (row 7 have to have something) and there will be only one TRUE per row.
 

Attachments

  • Tasks.xlsb
    543 KB · Views: 2
Last edited:
I am not sure but I think you mean this?
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    With Target
        ay = .Row
        ax = .Column
    End With
    With ActiveSheet
        If ay > 7 And .Cells(ay, "J") <> Empty Then
            xx = .Cells(7, .Columns.Count).End(xlToLeft).Column
            For x = 1 To xx
                yx = .Cells(ay, x)
                If yx = True Or yx = False Then
                    If yx = True Then yx = True
                    If x = ax Then yx = False
                    .Cells(ay, x) = yx
                End If
            Next x
        End If
    End With
End Sub
dubble click in the checkboxes, except the first. you click
 

Attachments

  • Tasks(1).xlsb
    541.7 KB · Views: 3
Last edited:
It should be one allowed per group. I will check attachments now.

Thanks everyone

See attached different version has 2 groups. Low, Medium, High Priority and Planned, Started, Done Status.
 

Attachments

  • Tasks V2.xlsb
    542.3 KB · Views: 0
That is perfect vietm! Thanks so much for your excellent help.

Perhaps this book can be useful to others in different scenarios.
 

BillyRay

... maybe, if there will use option-buttons like radiobuttons.
Checkboxes should be possible to select from none to all.

Maybe You got - what did You ask?
BUT ... is it - what do You need? Can You use it?
I mean
# what else do You have there?
# how would You use those?
~ eg it's possible to get unwanted some kind of chain reaction
 
Last edited:
I can schedule things to do or events that I need to attend. I can also set up projects. This workbook can be useful to keep track of what and when history to be used in case of repeating to know when last time the task was done.
 
Back
Top