Insertformula into a cell using relative values, based upon the criteria

  • Hi All!

    I need to paste in a formula into column AA9, based upon the criteria in column A9, and then loop down to the end up my data. As an example, if Column A9 = 600, I would paste in the formula =(0.5*Q9)+(X9*0.01), but if A7 = 602 then I would paste in the formula =IF(((X10-101.3-AB10-AC10-(0.35*X10))*0.2)>0,((X10-101.3-AB10-AC10-(0.35*X10))*0.2),0). I know how to do this, but my issue is, I am not sure how to paste these formulas in with the proper row number. When I loop down to AA10, I need the formula to use the cells in the row. For 600 it would be =(0.5*Q10)+(X10*0.01).

    This is what I have so far...

    Sub test()
    If Range("A9") = 600 Then
    Range("AA9").Formula = "=(0.5 * Q9) + (x9 * 0.01)"

    ElseIf Range("A9") = 602 Then
    Range("AA9").Formula = "=IF(((X9-101.3-AB9-AC9-(0.35*X9))*0.2)>0,((X9-101.3-AB9-AC9-(0.35*X9))*0.2),0)"
    End If

    End Sub

    This works for this once cell, but of course that is it... Thanks for any help you can provide!

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!