How to insert Data form Userfomr into Spreadsheet

Garden_Lily

New Member
Joined
Nov 27, 2017
Messages
1
Here is the code I have, but it is not working.
Private Sub CommandButton1_Click()
Dim emptyRow As Long
'Activate Data Request Worksheet
Sheets("Request Data").Activate
'Determine emptyRow
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
'Transfer information
Sheets("Data Request").Cells(emptyRow, 1).Value = ComboBox1.Value

Sheets("Data Request").Cells(emptyRow, 2).Value = TextBox4.Value
Sheets("Data Request").Cells(emptyRow, 3).Value = TextBox1.Value
Sheets("Data Request").Cells(emptyRow, 4).Value = TextBox2.Value

Sheets("Data Request").Cells(emptyRow, 5).Value = OptionButton3.Value
Sheets("Data Request").Cells(emptyRow, 6).Value = OptionButton4.Value
Sheets("Data Request").Cells(emptyRow, 7).Value = OptionButton5.Value
Sheets("Data Request").Cells(emptyRow, 8).Value = OptionButton6.Value
Sheets("Data Request").Cells(emptyRow, 9).Value = OptionButton1.Value
Sheets("Data Request").Cells(emptyRow, 10).Value = OptionButton2.Value

Sheets("Data Request").Cells(emptyRow, 11).Value = TextBox3.Value
Sheets("Data Request").Cells(emptyRow, 12).Value = OptionButton2.Value
Sheets("Data Request").Cells(emptyRow, 13).Value = OptionButton2.Value
Sheets("Data Request").Cells(emptyRow, 14).Value = OptionButton2.Value
Sheets("Data Request").Cells(emptyRow, 15).Value = OptionButton2.Value

If CheckBox3.Value = True Then
Sheets("Data Request").Cells(emptyRow, 16).Value = "Yes"
Else
Sheets("Data Request").Cells(emptyRow, 16).Value = "No"
End If
If CheckBox1.Value = True Then
Sheets("Data Request").Cells(emptyRow, 17).Value = "Yes"
Else
Sheets("Data Request").Cells(emptyRow, 17).Value = "No"
End If
If CheckBox2.Value = True Then
Sheets("Data Request").Cells(emptyRow, 18).Value = "Yes"
Else
Sheets("Data Request").Cells(emptyRow, 18).Value = "No"
End If
If CheckBox4.Value = True Then
Sheets("Data Request").Cells(emptyRow, 19).Value = "Yes"
Else
Sheets("Data Request").Cells(emptyRow, 19).Value = "No"
End If
If CheckBox5.Value = True Then
Sheets("Data Request").Cells(emptyRow, 20).Value = "Yes"
Else
Sheets("Data Request").Cells(emptyRow, 20).Value = "No"
End If
If CheckBox6.Value = True Then
Sheets("Data Request").Cells(emptyRow, 21).Value = "Yes"
Else
Sheets("Data Request").Cells(emptyRow, 21).Value = "No"
End If
If CheckBox7.Value = True Then
Sheets("Data Request").Cells(emptyRow, 22).Value = "Yes"
Else
Sheets("Data Request").Cells(emptyRow, 22).Value = "No"
End If

End Sub
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Hi,
welcome to forum.

You don't say in what way your code is not working but I suspect this line:

Rich (BB code):
'Activate Data Request Worksheet
Sheets("Request Data").Activate

should be

Rich (BB code):
'Activate Data Request Worksheet
Sheets("Data Request").Activate

Dave
 
Upvote 0

Forum statistics

Threads
1,223,887
Messages
6,175,199
Members
452,617
Latest member
Narendra Babu D

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top