I hope someone can help me.
I am new to creating userforms, but I have managed to set one up, but I need to set up a 'submit' button that will in a sense save the data in a field and clear the form.
Below is the script I have written (most likely gibberish). when I press the button it says there is an issue and debug doesn't help me.
Please help
Thank you
Matt
Sub cmd_enter_Click()
Dim emptyRow As Long
'Make Sheet2 active
Sheet2.Activate
'Determine emptyRow
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
'Transfer information
Cells(emptyRow, 1).Value = combo_centre.Value
Cells(emptyRow, 2).Value = Text_course.Value
Cells(emptyRow, 3).Value = Text_datefrom.Value
Cells(emptyRow, 4).Value = Text_dateto.Value
Cells(emptyRow, 6).Value = Text_studentno.Value
Cells(emptyRow, 7).Value = Text_staffno.Value
Cells(emptyRow, 8).Value = Text_where.Value
Cells(emptyRow, 9).Value = Opt_uk.Value
Cells(emptyRow, 10).Value = opt_eu.Value
Cells(emptyRow, 11).Value = opt_usa.Value
If Opt_uk.Value = True Then
Cells(emptyRow, 9).Value = "Yes"
Else
Cells(emptyRow, 9).Value = ""
If opt_eu.Value = True Then
Cells(emptyRow, 10).Value = "Yes"
Else
Cells(emptyRow, 10).Value = ""
If opt_usa.Value = True Then
Cells(emptyRow, 11).Value = "Yes"
Else
Cells(emptyRow, 11).Value = ""
'Set Focus on combo_centre
combo_centre.SetFocus
ThisWorkbook.Save
End Sub
I am new to creating userforms, but I have managed to set one up, but I need to set up a 'submit' button that will in a sense save the data in a field and clear the form.
Below is the script I have written (most likely gibberish). when I press the button it says there is an issue and debug doesn't help me.
Please help
Thank you
Matt
Sub cmd_enter_Click()
Dim emptyRow As Long
'Make Sheet2 active
Sheet2.Activate
'Determine emptyRow
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
'Transfer information
Cells(emptyRow, 1).Value = combo_centre.Value
Cells(emptyRow, 2).Value = Text_course.Value
Cells(emptyRow, 3).Value = Text_datefrom.Value
Cells(emptyRow, 4).Value = Text_dateto.Value
Cells(emptyRow, 6).Value = Text_studentno.Value
Cells(emptyRow, 7).Value = Text_staffno.Value
Cells(emptyRow, 8).Value = Text_where.Value
Cells(emptyRow, 9).Value = Opt_uk.Value
Cells(emptyRow, 10).Value = opt_eu.Value
Cells(emptyRow, 11).Value = opt_usa.Value
If Opt_uk.Value = True Then
Cells(emptyRow, 9).Value = "Yes"
Else
Cells(emptyRow, 9).Value = ""
If opt_eu.Value = True Then
Cells(emptyRow, 10).Value = "Yes"
Else
Cells(emptyRow, 10).Value = ""
If opt_usa.Value = True Then
Cells(emptyRow, 11).Value = "Yes"
Else
Cells(emptyRow, 11).Value = ""
'Set Focus on combo_centre
combo_centre.SetFocus
ThisWorkbook.Save
End Sub