View Full Version : Solved: LastRow.Offset but for Colomn
white_flag
03-25-2010, 05:32 AM
Hello
it is an way to have this
LastRow.Offset(1, 0).Value = TextBox1.Text
LastRow.Offset(1, 1).Value = TextBox2.Text
LastRow.Offset(1, 2).Value = TextBox3.Text
LastRow.Offset(1, 3).Value = TextBox4.Text
but for column usage.
thx
white_flag
03-25-2010, 05:49 AM
sorry:
Private Sub CommandButton2_Click()
Dim LastRow As Object
Set LastRow = Sheet1.Range("a65536").End(xlUp)
LastRow.Offset(1, 3).Value = TextBox2.Text
LastRow.Offset(1, 4).Value = TextBox3.Text
LastRow.Offset(1, 5).Value = TextBox4.Text
MsgBox "Do you want to enter another record?", vbYesNo
If vbYes Then
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox1.SetFocus
Else
Unload Me
End If
End Sub
this code put the text like this 1 2 3 4 5 etc ...
I will like to be putted like this:
1
2
3
4
5
etc...
Bob Phillips
03-25-2010, 06:10 AM
Untested
Private Sub CommandButton2_Click()
Dim LastRow As Object
Set LastRow = Sheet1.Range("a65536").End(xlUp)
LastRow.Offset(1, 1).Value = TextBox2.Text
LastRow.Offset(2, 1).Value = TextBox3.Text
LastRow.Offset(3, 1).Value = TextBox4.Text
MsgBox "Do you want to enter another record?", vbYesNo
If vbYes Then
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox1.SetFocus
Else
Unload Me
End If
End Sub
white_flag
03-25-2010, 02:45 PM
thx, xld
in the end the code is looking like this
Private Sub CommandButton2_Click()
Dim LastCol As Range
Set LastCol = Sheet1.Range("IV2").End(xlToLeft)
LastCol.Offset(0, 1).Value = TextBox1.Text 'name
LastCol.Offset(1, 1).Value = TextBox2.Text 'diametru
LastCol.Offset(2, 1).Value = TextBox4.Text 'Lenght
MsgBox "Do you want to enter another record?", vbYesNo
If vbYes Then
TextBox1.Text = ""
TextBox2.Text = ""
TextBox4.Text = ""
TextBox1.SetFocus
Else
Unload Me
End If
End Sub
but it is almost the same :)
mdmackillop
03-25-2010, 04:32 PM
Please use the green VBA button to get your code formatted on this site
Regards
MD
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.