Forum Discussion

cking1333's avatar
cking1333
Copper Contributor
Jul 23, 2024
Solved

When checkbox selected, enter specific value into spreadsheet

Greetings,    I have a userform that contains multiple checkboxes that, when checked, I would like to enter "Y" or "N" into a spreadsheet. I'm getting an error when I use an IF statement on line 18...
  • HansVogelaar's avatar
    Jul 23, 2024

    cking1333 

    You cannot use If ... Then this way.

    You can use an If .. Then block:

        If DTTCheckBox.Value = True Then
            .Range("O" & lr).Value = "Y"
        Else
            .Range("O" & lr).Value = "N"
        End If

    Or you can use the IIf (Immediate If) function:

        .Range("O" & lr).Value = IIf(DTTCheckBox.Value = True, "Y", "N")

Resources