Hello,
I am trying to add data to a worksheet through a UserForm. I have 6 rows of data in the UserForm with 3 columns of text boxes and 1 column with option buttons. I am running into an issue where the option buttons are being inserted after the text boxes, so i have the text box data all on the correct rows, then that data is repeated with the data from the option buttons. So if I enter three rows of new information I will end up with the three rows for the text boxes and then another three rows for the option buttons.
I am also running into an issue where I can only check off one option button. There will be times where all of some of the buttons will be checked off. How do I make it so multiple can be checked?
I need each row to transfer over on the same line, which is happening for the text boxes, just not the option button. Also need to be able to check off multiple buttons, not just one. Thank you for your help
I am trying to add data to a worksheet through a UserForm. I have 6 rows of data in the UserForm with 3 columns of text boxes and 1 column with option buttons. I am running into an issue where the option buttons are being inserted after the text boxes, so i have the text box data all on the correct rows, then that data is repeated with the data from the option buttons. So if I enter three rows of new information I will end up with the three rows for the text boxes and then another three rows for the option buttons.
I am also running into an issue where I can only check off one option button. There will be times where all of some of the buttons will be checked off. How do I make it so multiple can be checked?
VBA Code:
Private Sub CommandButton1_Click()
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("DATA Member-19")
LastRow = ws.Cells(Rows.Count, 4).End(xlUp).Row
ws.Cells(LastRow + 1, 2).Value = TextBox1.Value
ws.Cells(LastRow + 2, 2).Value = TextBox2.Value
ws.Cells(LastRow + 3, 2).Value = TextBox3.Value
ws.Cells(LastRow + 4, 2).Value = TextBox4.Value
ws.Cells(LastRow + 5, 2).Value = TextBox5.Value
ws.Cells(LastRow + 6, 2).Value = TextBox6.Value
ws.Cells(LastRow + 1, 3).Value = TextBox7.Value
ws.Cells(LastRow + 2, 3).Value = TextBox8.Value
ws.Cells(LastRow + 3, 3).Value = TextBox9.Value
ws.Cells(LastRow + 4, 3).Value = TextBox10.Value
ws.Cells(LastRow + 5, 3).Value = TextBox11.Value
ws.Cells(LastRow + 6, 3).Value = TextBox12.Value
ws.Cells(LastRow + 1, 4).Value = TextBox13.Value
ws.Cells(LastRow + 2, 4).Value = TextBox14.Value
ws.Cells(LastRow + 3, 4).Value = TextBox15.Value
ws.Cells(LastRow + 4, 4).Value = TextBox16.Value
ws.Cells(LastRow + 5, 4).Value = TextBox17.Value
ws.Cells(LastRow + 6, 4).Value = TextBox18.Value
If OptionButton1.Value = True Then ws.Cells(LastRow + 1, 15).Value = "X": OptionButton1.Value = ""
If OptionButton2.Value = True Then ws.Cells(LastRow + 2, 15).Value = "X": OptionButton2.Value = ""
If OptionButton3.Value = True Then ws.Cells(LastRow + 3, 15).Value = "X": OptionButton3.Value = ""
If OptionButton4.Value = True Then ws.Cells(LastRow + 4, 15).Value = "X": OptionButton4.Value = ""
If OptionButton5.Value = True Then ws.Cells(LastRow + 5, 15).Value = "X": OptionButton5.Value = ""
If OptionButton6.Value = True Then ws.Cells(LastRow + 6, 15).Value = "X": OptionButton6.Value = ""
MsgBox ("Members added successfully")
End Sub
I need each row to transfer over on the same line, which is happening for the text boxes, just not the option button. Also need to be able to check off multiple buttons, not just one. Thank you for your help