I recorded a macro that calculates using SUMIF and then autofills.
Range("H2").Select
ActiveCell.FormulaR1C1 = "=SUMIF(RC[-5], ""10"", RC[-4])"
Range("H2").Select
Selection.AutoFill Destination:=Range("H2:H3798")
Range("H2:H3798").Select
Is there a way to adjust the code so that it recognizes if the range is bigger or smaller than the "H2:H3798" range I used to make the macro? The data will always start at "H2" but will always have a different end range.
I tried to adjust it so it read "H2:H" & lastRow" but that led to a runtime error.