0

Upon clicking run, I kept getting the runtime error 1004 and the codes in brackets below gets highlighted. Any one can help me with this

Private Sub Add_Click()

  Sheet4.Activate 
  (Range("A1").End(x1Down).Offset(1, 0).Select)

  ActiveCell.Value = ActiveCell.Offset(-1, 0).Value + 1
  ActiveCell.Offset(0, 1).Value = TextBox1.Value
  ActiveCell.Offset(0, 2).Value = TextBox2.Value
  ActiveCell.Offset(0, 3).Value = TextBox3.Value
  ActiveCell.Offset(0, 4).Value = ComboBox1.Value
  ActiveCell.Offset(0, 5).Value = ComboBox2.Value
  ActiveCell.Offset(0, 6).Value = TextBox4.Value

End Sub
1
  • You have a misprint - x1Down instead of xlDown. x1Down is treated as a variable name, which not exists. Use Intellisense if you are not careful.
    – Akina
    Oct 18, 2018 at 6:51

1 Answer 1

-1

To get rid from the error replace row 2, 3 & 4 with this:

Worksheets("Sheet4").Activate 
Range("A1").End(xlDown).Offset(1, 0).Select
ActiveCell.Value = ActiveCell.Offset(-1, 0).Value

Note, End(x1Down) should written like End(xlDown), as also been suggested by @AKINA in comments above.

1
  • Unnecessarily down voted since working properly !! Oct 25, 2018 at 7:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .