beanhead0321
New Member
- Joined
- Jul 8, 2011
- Messages
- 14
I have a UserForm with 4 textboxes on it. When I press the Okay commandbutton, it puts the text in these 4 textboxes into cells B2, C2, D2, and E2, and the date in A2, then clears the form. However, I don't know how to make it so that the next time the form is filled out, the data goes into B3, C3, D3, and E3 and the date into A3 and so on. I think I have to use a Loop, but I'm a VBA noobie and I don't know how. Thanks in advanced. This is the code that I have now for my commandbutton.
Private Sub CommandButton1_Click()
Range("A2").Value = Date
Range("B2").Value = TextBox1.Value
Range("C2").Value = TextBox2.Value
Range("D2").Value = TextBox3.Value
Range("E2").Value = TextBox4.Value
TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
TextBox4.Value = ""
End Sub
Private Sub CommandButton1_Click()
Range("A2").Value = Date
Range("B2").Value = TextBox1.Value
Range("C2").Value = TextBox2.Value
Range("D2").Value = TextBox3.Value
Range("E2").Value = TextBox4.Value
TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
TextBox4.Value = ""
End Sub