Hi everyone,
I am building a reporting tool for students and I managed to saved the data which is inputted into a userform to anexcel spreadsheet. When a student click the submit button (CommandButton1) I want all contents in the useform to be cleared so another student can fill in the form with a new Project ID. This is the code I used so far:
Private Sub CommandButton1_Click()
Dim NextFreeRow As Long
NextFreeRow = Range("a65536").End(xlUp).Row + 1
Cells(NextFreeRow, 1) = ProjectID.Value
Cells(NextFreeRow, 2) = TextBox9.Text
Cells(NextFreeRow, 3) = Creator.Text
Cells(NextFreeRow, 4) = TextBox35.Text
Cells(NextFreeRow, 5) = TextBox66.Text
Cells(NextFreeRow, 6) = ComboBox6.Value
Cells(NextFreeRow, 7) = ComboBox8.Value
Cells(NextFreeRow, 8) = TextBox18.Text
Cells(NextFreeRow, 9) = TextBox38.Text
Cells(NextFreeRow, 10) = Title.Text
Cells(NextFreeRow, 11) = TextBox7.Text
Cells(NextFreeRow, 12) = TextBox65.Text
Cells(NextFreeRow, 13) = CheckBox1.Value
Cells(NextFreeRow, 14) = TextBox39.Text
Cells(NextFreeRow, 15) = TextBox4.Text
Cells(NextFreeRow, 16) = TextBox36.Text
Cells(NextFreeRow, 17) = ComboBox3.Text
Cells(NextFreeRow, 18) = TextBox12.Text
Cells(NextFreeRow, 19) = TextBox20.Text
Cells(NextFreeRow, 20) = TextBox19.Text
Exit Sub
Can anyone provide me with the code 1. clear contents after submission 2. generate a new project ID after submission and It would be also helpful to specify the Worksheet I am saving the data in to.
Thanks
Gordon
Bookmarks