-1

I am using a formula in excel to add all the data with the same date in the column before with =SUMIF(A2:A150,C1,B2:B150)

Is there any way to copy the formula down the column but with the same range but different row: =SUMIF(A2:A150,C(the row it is in),B2:B150)

Instead, when i copy the formula down the column, it does: =SUMIF(A3:A151,C2,B3:B151) and adds one to every value.

Is there any way to use a variable to only change the row, Thanks.

Community
  • 1
  • 1
Irfan
  • 1
  • 1

2 Answers2

0

Make the sum range and criteria range row absolute.

range("d1:d149").formula = "=SUMIF(A$2:A$150, C1, B$2:B$150)"
0

Try this

=SUMIF($A$2:$A$150,$C1,$B$2:$B$150)

Putting $ sign locks the cell range. Alternatively, you can use F4 on your keyboard to lock cells, F4 puts the $ automatically with you the need for typing.