-1

This Macro adds data in Cell A10. Now the data gets overwritten every time i run it again. How can i add 1 cel below?

Sub Invoer()


Dim Debiteurnummer As Integer
Dim Aantalpallets As Integer
Dim Totaalgewicht As Integer

Debiteurnummer = InputBox("Debiteurnummer invoeren")
Aantalpallets = InputBox("Aantal Pallets?")
Totaalgewicht = InputBox("Totaal Gewicht?")

Range("A10").Value = Debiteurnummer
Range("A10").Offset(0, 2) = Aantalpallets
Range("A10").Offset(0, 3) = Totaalgewicht




End Sub
Rubinjo13
  • 65
  • 2
  • 11
  • Please see [THIS](http://stackoverflow.com/questions/11169445/error-in-finding-last-used-cell-in-vba/11169920#11169920). Also see why use `Long` instead of `Integer`. By the way `Range("A10").Offset(0, 2)` can be written as `Range("C10")` and `Range("A10").Offset(0, 3)` can be written as `Range("D10")` – Siddharth Rout Jul 28 '16 at 08:51

1 Answers1

0

Add a dynamic search for LastRow:

Sub Invoer()

Dim Debiteurnummer As Integer
Dim Aantalpallets As Integer
Dim Totaalgewicht As Integer
Dim LastRow As Long

Debiteurnummer = InputBox("Debiteurnummer invoeren")
Aantalpallets = InputBox("Aantal Pallets?")
Totaalgewicht = InputBox("Totaal Gewicht?")

LastRow = Cells(Rows.count, "A").End(xlUp).row

Range("A" & LastRow + 1).Value = Debiteurnummer
Range("A" & LastRow + 1).Offset(0, 2) = Aantalpallets
Range("A" & LastRow + 1).Offset(0, 3) = Totaalgewicht

End Sub
Shai Rado
  • 33,032
  • 6
  • 29
  • 51