Populate new row with VBA button click
- by AME
Hi,
I am trying to create a list that adds a new row of data each time a button is clicked. I have the following code assigned to the button when clicked:
PurchaseDate = InputBox("Enter Purchase Date:")
Sheets("TrackRecord").Select
i = 0
Row = i + 1
Range("A2").Select
ActiveCell.FormulaR1C1 = Row
Range("B2").Select
ActiveCell.FormulaR1C1 = "=Dashboard!R26C4*(1/Dashboard!R26C12)"
Range("C2").Select
ActiveCell.FormulaR1C1 = "=Dashboard!R26C2"
Range("D2").Select
ActiveCell.FormulaR1C1 = PurchaseDate
Range("E2").Select
ActiveCell.FormulaR1C1 = "=Dashboard!R26C8 + R2C4"
Range("F2").Select
ActiveCell.FormulaR1C1 = "=Waterfall!R[8]C[5]"
Range("F2").Select
Selection.AutoFill Destination:=Range("F2:I2"), Type:=xlFillDefault
Range("F2:I2").Select
End Sub
This code works fine, but I'd like it populate the next row below instead of overwriting the same row each time the button is clicked. I know that I have to iterate through the "Range("A2").select" section, e.g. "Range("A2").select" -- "Range("B2").select" .. But I don't know how to do this in VBA for Excel. That's why I am asking you folks ; ) .
Thanks,