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

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like