G
George
Below I have the following code. A userform with textboxes. When I press
commandbutton 1 it transfirs all the data to the worksheet.
How can I insert a command so that the active cell selected is the next
empty row down in column "A".
Private Sub CommandButton1_Click()
Dim lastrow As Object
Set lastrow = Sheet1.Range("a65536").End(xlUp)
lastrow.Offset(1, 0).Value = TextBox2.Text
lastrow.Offset(1, 1).Value = TextBox1.Text
lastrow.Offset(1, 2).Value = TextBox8.Text
lastrow.Offset(1, 3).Value = TextBox3.Text
lastrow.Offset(1, 4).Value = TextBox4.Text
lastrow.Offset(1, 7).Value = TextBox7.Text
MsgBox "One record written to Data Sheet"
response = MsgBox("Do you want to enter another record?", vbYesNo)
If response = vbYes Then
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox7.Text = ""
TextBox8.Text = ""
TextBox1.SetFocus
Else
Unload Me
End If
End Sub
commandbutton 1 it transfirs all the data to the worksheet.
How can I insert a command so that the active cell selected is the next
empty row down in column "A".
Private Sub CommandButton1_Click()
Dim lastrow As Object
Set lastrow = Sheet1.Range("a65536").End(xlUp)
lastrow.Offset(1, 0).Value = TextBox2.Text
lastrow.Offset(1, 1).Value = TextBox1.Text
lastrow.Offset(1, 2).Value = TextBox8.Text
lastrow.Offset(1, 3).Value = TextBox3.Text
lastrow.Offset(1, 4).Value = TextBox4.Text
lastrow.Offset(1, 7).Value = TextBox7.Text
MsgBox "One record written to Data Sheet"
response = MsgBox("Do you want to enter another record?", vbYesNo)
If response = vbYes Then
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox7.Text = ""
TextBox8.Text = ""
TextBox1.SetFocus
Else
Unload Me
End If
End Sub