![]() |
Adding data to a worksheet from a UserForm
Hello all, I am trying to get my head around adding data to a worksheet
via a userform. I want to add to lists in sheet 3 in the next available row but I keep getting a application-defined or object defined error. Debug points me to the 2nd line of the macro. (Set LastRow). Can any one help? Thanks Kezza Private Sub CommandButton6_Click() Dim LastRow As Object Set LastRow = Sheet3.Range("a65536").End(x1Up) LastRow.Offset(1, 0).Value = TextBox6.Text LastRow.Offset(1, 1).Value = TextBox7.Text LastRow.Offset(1, 2).Value = TextBox8.Text MsgBox "One record written to Sheet3" response = MsgBox("Do you want to enter another record?", vbYesNo) If response = vbYes Then TextBox6.Text = "" TextBox7.Text = "" TextBox8.Text = "" TextBox6.SetFocus Else Unload Me End If End Sub |
Adding data to a worksheet from a UserForm
pls modify your code like this:
Dim LastRow As Range Set LastRow = Sheet3.Range("a65536").End(xlUp) "Kezza" wrote: Hello all, I am trying to get my head around adding data to a worksheet via a userform. I want to add to lists in sheet 3 in the next available row but I keep getting a application-defined or object defined error. Debug points me to the 2nd line of the macro. (Set LastRow). Can any one help? Thanks Kezza Private Sub CommandButton6_Click() Dim LastRow As Object Set LastRow = Sheet3.Range("a65536").End(x1Up) LastRow.Offset(1, 0).Value = TextBox6.Text LastRow.Offset(1, 1).Value = TextBox7.Text LastRow.Offset(1, 2).Value = TextBox8.Text MsgBox "One record written to Sheet3" response = MsgBox("Do you want to enter another record?", vbYesNo) If response = vbYes Then TextBox6.Text = "" TextBox7.Text = "" TextBox8.Text = "" TextBox6.SetFocus Else Unload Me End If End Sub |
All times are GMT +1. The time now is 12:23 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com