Hello all! I'm trying to create a very basic userform for data entry. I have watched tons of tutorials and found several sets of code to do this but none of them seem to work in my project. Below is some code that I've tried and I keep getting a run-time error and I cannot figure out why. Thanks for any help. The attached sheet only has 1 combo box in the userform to simplify this and I will adjust the code as I add more controls. The error seems to point to the "Set nextrow" line.
Private Sub UpdateSheet_Click()
Dim cNum As Integer
Dim X As Integer
Dim Teams As String
Dim nextrow As Range
Dim sht As String
'set the variable for the sheet
sht = TeamCombobox.Value
'check for values
If Me.TeamCombobox.Value = "" Then
MsgBox "Select a sheet from the combobox and add the date"
Exit Sub
End If
'change the number for the number of controls on the userform
cNum = 1
'add the data to the selected worksheet
Set nextrow = Sheets(sht).Cells(Rows.Count, 3).End(xlUp).Offset(1, 0)
For X = 1 To cNum
nextrow = Me.Controls("Reg" & X).Value
Set nextrow = nextrow.Offset(0, 1)
Next
'clear the values in the userform
For X = 1 To cNum
Me.Controls("Reg" & X).Value = ""
Next
'communicate the results
MsgBox "The values have been sent to the " & sht & " sheet"
End Sub
Bookmarks