Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
selecting the next cell down
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 -- George |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
selecting the next cell down
Try:
lastrow.Offset(2, 0).Select This will move you past the data that you have just entered -- Gary's Student "George" wrote: 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 -- George |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
selecting the next cell down
Thanks Gary that was quick.
How would I place it in the code included on my question. Or would it go in as a seperate code? -- George "Gary''s Student" wrote: Try: lastrow.Offset(2, 0).Select This will move you past the data that you have just entered -- Gary's Student "George" wrote: 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 -- George |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Help with this conditional IF statement | Excel Discussion (Misc queries) | |||
Instead of a negative number, I'd like to show zero... | Excel Worksheet Functions | |||
Possible Lookup Table | Excel Worksheet Functions | |||
Copy cell format to cell on another worksht and update automatical | Excel Worksheet Functions | |||
up to 7 functions? | Excel Worksheet Functions |