Here is the piece that has the sum if and the variable used. The rest of the macro is long and proprietary so I can't post it.
I am going by the logic of the sumif formula of sumif(range to be searched, seach for this, sum this range)
Dim rownum1 as variant, dim rownum2 as variant, dim rownum3 as variant
Dim openrow as integer
dim lastrow as integer
rownum1= cells(lastrow,2)
rownum2=cells(openrow,2)
rownum3=cells(lastrow,3)
cells(openrow,4).formula = "=sumif(b2:" & rownum1 & "," & rownum2 & ",c3:" & rownum3 &")"
This way as the variables for lastrow and openrow increase, the formula will move down the sheet and the criteria range will expand.
Bookmarks