Im trying to create a macro that is a sumif function. The sumif function must show up in the cell as a regular formula. I also need to use the xlup function as my data will be of various rows. Right now my code is
    Dim sum_range As Range
    Dim criteria_range As Range
    Set sum_range = Range("O2", Range("O" & Rows.Count).End(xlUp))
    Set criteria_range = Range("J2", Range("J" & Rows.Column).End(xlUp))
    Application.WorksheetFunction.SumIf(criteria_range, Range("J2"), sum_range) = Range("T2")
However I get an error stating "assignment to constant not permitted?"

Any suggestions. FormulaR1C1 works but only if the # of rows doesn't vary. I need something that allows me to use xldown/xlup