Excel Vba Runtime Error 1004 Application-Defined or Object-Defined Error

Excel Vba Runtime Error 1004 Application-Defined or Object-Defined Error

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

1 Answer

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

David Miller
Author

David Miller

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.