Forum Discussion
cking1333
Jul 23, 2024Copper Contributor
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...
- Jul 23, 2024
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")
HansVogelaar
Jul 23, 2024MVP
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")
- cking1333Jul 24, 2024Copper ContributorThanks HansVogelaar!!!