View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Kezza Kezza is offline
external usenet poster
 
Posts: 13
Default 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