Add Subtraction Formula To Cell Via Code

  • Hi,


    If I wish to amend the below code such that it must use the cell one row above minus the cell on the left, how should I go about it?


    Eg,


    If in cell C10, the formula is to use C9 minus B10.
    If in cell C11, the formula is to use C10 minus B11.


    Code
    mylogoff.Offset(0, 1).FormulaR1C1 = "=RC[-1]-RC[-2]


    Thanks for any advice.
    Gon:)

  • Re: Add Subtraction Formula To Cell Via Code


    "Hi norie, thank you for the reply.


    But if I changed -2 to -1, the formula actual minus from the same cell.


    I attached file for reference. Under the "balance" column, it should use the balance hours minus the current day hour. Eg cell E4 = E3 - D4


    Any advise is greatly appreciated.


    Thanks,
    Gon[hr]*[/hr] Auto Merged Post;[dl]*[/dl]Oops, forgot to attach the file. Here it is.

  • Re: Add Subtraction Formula To Cell Via Code


    assuming mylogoff is/are cell(s) in column D then:

    Code
    mylogoff.Offset(0, 1).FormulaR1C1 = "=R[-1]C-RC[-1]"

    should do it, p45cal

Participate now!

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