Hi,
I'm new to VBA and having some difficulty getting a sumif to work within a larger macro. Currently it is returning zeros in column I.
I'm trying to loop this part of the macro so that it runs through a range of criteria one at a time (in column H), identifies matching criteria in column E, and returns the sum of the cells from column C corresponding to column E. I want to place the summed values in Column I, next to their corresponding criteria in column H.
In the below code:
RangeofCriteria = the number of rows in the list of criteria. I would like to essentially conduct a sumif for each of these criteria, hence the loop.
TopRowofCriteria = the row number for the first row in column H for which I would like to conduct a sumif - also the first row where I would like to place the first value in Column I
TopRowofSumRange = the row number for the top row of my matching criteria, also for the sum range
EndRowofSumRange = the row number for the last row of my matching criteria, also for the sum range
Here is the code:
For i = 0 To RangeofCriteria
Cells(TopRowofCriteria + i, "I").Value = Application.WorksheetFunction.sumif(Sheets("Timelog").Range("C" & TopRowofSumRange, "C" & EndRowofSumRange), Sheets("Timelog").Cells(TopRowofCriteria + i, "H").Value, Sheets("Timelog").Range("E" & TopRowofSumRange, "E" & EndRowofSumRange))
Next i
I would really appreciate any help.
Thanks.
Bookmarks