Reputation: 123
I have created a vba to change the options in Userform and partially succeeded. But am unable to change the data for Option button and Checkbox. I get a message as"False" in that row. Please help me out!
Private Sub cmdupdate_Click()
If Me.cmbslno.Value = "" Then
MsgBox "SL No Can Not be Blank!", vbExclamation, "SL No"
Exit Sub
End If
SLNo = Me.cmbslno.Value Sheets("Data").Select
Dim rowselect As Double
rowselect = Me.cmbslno.Value
rowselect = rowselect + 3
Rows(rowselect).Select
Cells(rowselect, 2) = Me.TextEmpCode.Value
Cells(rowselect, 3) = Me.TextEmpName.Value
**Cells(rowselect, 5) = Me.Option1.Value
Cells(rowselect, 5) = Me.Option2.Value
Cells(rowselect, 5) = Me.Option3.Value**
Cells(rowselect, 17) = Me.TextBox1.Value
Cells(rowselect, 18) = Me.TextBox2.Value
Cells(rowselect, 19) = Me.TextBox3.Value
Cells(rowselect, 20) = Me.TextIncome.Value
End Sub
Upvotes: 2
Views: 1332
Reputation: 3188
Do you want to put "Option 1", "Option 2" or "Option 3" in the cell?
Change the following:
Cells(rowselect, 5) = Me.Option1.Value
Cells(rowselect, 5) = Me.Option2.Value
Cells(rowselect, 5) = Me.Option3.Value
To
Cells(rowselect, 5) = IIf(Me.Option1.Value, "Option 1", IIf(Me.Option2.Value, "Option 2", "Option 3"))
Upvotes: 3
Reputation: 43585
Can you check like this:
Cells(rowselect, 21) = Me.Option1.Value
Cells(rowselect, 22) = Me.Option2.Value
Cells(rowselect, 23) = Me.Option3.Value
The column 5
is given 3 times, they are overlapping each time.
Upvotes: 0