VBA Code:
Range("G3").FormulaR1C1 = "=SUMIF(R[13]C[1]:R[42]C[1],RC[1],R[13]C:R[42]C)"
I had the code above, but I want to change it so that it goes to the last row in the worksheet.
I changed it to:
VBA Code:
Dim lastRow As Long
lastRow = Cells(Rows.Count, "A").End(xlUp).Row
' Adjust the SUMIF formula ranges to absolute references
Range("G3").FormulaR1C1 = "=SUMIF(R16C17:R" & lastRow & "C17,RC[1],R16C16:R" & lastRow & "C16)"
but the final formula after the VBA is
Excel Formula:
=SUMIF($C$16:$C$26,Q3,$B$16:$B$26)
Excel Formula:
=SUMIF($Q$15:$Q$26,Q3,$P$15:$P$26)
Can somebody please tell me how to fix this?