Forum Discussion
How do I use the variable total rows number in a formula?
Hi all,
I enter time information into an Excel sheet over the course of a month, and so the total number of rows is a variable and always changes. I also have multiple jobs per month, all of which is identified by a job number. I want to calculate the total hours for each job group for the whole month. The hours values are in the "L" column. My job numbers are in the "D" column. My current equation: =IF(COUNTIF(D$2:D3,D3)>1,"",SUMIF(D3:D116,D3,L3:L116)) goes to only row 116 for the first row. The problem is if the number of rows exceed 116, and I get new tasks for those jobs set to only look up to row 116, the total hours will not be accurate.
I tried adding a row counter column, and then calculating the max counter in a cell, and I named that cell "MAXROWS". I want the equation to work like:
=IF(COUNTIF(D$2:D3,D3)>1,"",SUMIF($D3:$DMAXROWS,D3,$L3:$LMAXROWS))
How can I do this? Is there another way to do this?
Thanks!
1 Reply
- SergeiBaklanDiamond Contributor
Hi Christine,
Instead of D3:D116, etc., you may use
OFFSET(D3,0,0,COUNTA(D3:D1000)))
assuming you have blank cells below your data. Or use Excel tables.