Populate new row with VBA button click

Posted by AME on Stack Overflow See other posts from Stack Overflow or by AME
Published on 2010-04-07T01:27:19Z Indexed on 2010/04/07 1:33 UTC
Read the original article Hit count: 308

Filed under:

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,

© Stack Overflow or respective owner

Related posts about excel-vba