I have an excel formula =SUM(AZ2:AZ300)
I want to make this more dynamic by using the formula =ROW(OFFSET($B$1,COUNTA($B:$B)-1,0)) in cell A1
Then I want my formula to do the following =SUM(AZ2:AZ&A1)
This formula doesn't work, but it to take the sum of cells AZ2 through AZ and the number given in cell A1
For example if A1 value is 250 then I want the formula to be equivalent to =SUM(AZ2:AZ250)
Thanks in advance for your help.
Rather than putting the row number in a separate cell you could combine it in the formula:
=SUM($A$2:INDEX($A:$A,COUNTA($B:$B)-1))
This does the same as the OFFSET version, with the bonus of not being volatile.
Related
My problem:
I have the below tables:
In my second table (tbl_analysis), I need to create a formula in the Sum column that will sum the salary of a certain person over a certain period. When the period changes, the formula needs to be recalculated.
My try:
I started off by using the formula:
=SUM(my_range)
By the range can't be hard-coded, so I decided to find the cell address of the corresponding month as you can see in the range D12:E15
Formula in the cell D12:
=CELL("address",INDEX($A$2:$M$8,MATCH(A12,$A$2:$A$8,0),MATCH(B12,$A$2:$M$2,0)))
So when I tried to insert the above formula inside of the SUM formula like this:
=SUM(CELL("address",INDEX($A$2:$M$8,MATCH(A12,$A$2:$A$8,0),MATCH(B12,$A$2:$M$2,0)))
: CELL("address",INDEX($A$2:$M$8,MATCH(A12,$A$2:$A$8,0),MATCH(C12,$A$2:$M$2,0))))
And then Excel is referecing the cell address itself and not the address inside of the formula.
Skip the Addresses and use this based on the months:
=SUM(INDEX(A:M,MATCH(A12,A:A,0),MATCH(B12,$2:$2,0)):INDEX(A:M,MATCH(A12,A:A,0),MATCH(C12,$2:$2,0)))
Scott Craner has the right solution for this scenario and it makes more sense here. However if you would absolutely need to get cell reference from a cell you would be able to do it using the following function:
INDIRECT(cell)
Usually this isn't necessary but it can be handy when you want to break up a long formula where you would need to find a row number for example.
INDIRECT("A" & B2)
Where B2 has the row number for a dynamic range or specific moving target row.
INDIRECT function documentation
Suppose I have a discontinuous range of cells from a single column in a SUM formula (ie., SUM(A1:A3, A5), is there formula I can use that will tell me that 4 cells are being used in that sum, or tell me the number of cells being used in a sum in general? I'd like to have the sum formula result and in the cell next to it the number of cells being used by the sum. I'd prefer an approach without using VBA if possible.
EDIT: I wasn't as specific as I should have been and for that I apologize. Using SUM(A1:A3,A5) again, let's say this formula exists in cell A7. Is there an Excel formula or function I can use to refer to cell A7 which yields the number of cells it's using in the sum? I know I can use the COUNT function to accomplish this, but I'm trying to make this dynamic so that the formula I'm looking for depends of the number of cells being summed and every time there is a change in the number of cells being summed, this other formula or function detects it automatically.
With a continuous range, you can get the total cell count (used cells and empty cells) with something like:
=COUNTA(A1:B9)+COUNTBLANK(A1:B9)
but =COUNTBLANK() won't support discontinuous ranges, so use:
=COUNTA(A1:A3, A5)+SUM(COUNTBLANK(INDIRECT({"A1:A3","A5"})))
(I know it is ugly.)
I'm using an array formula to calculate the second-largest value in each of Columns B-Z, conditional on the values being with a certain date range in Column A. Cells J2 and J3 contain the date ranges for IF function.
The formula I'm using is as follows:
{=LARGE(IF(($A$4:$A$4054>=$J$2)*($A$4:$A$4054<=$J$3),B4:B4054),2))}
In the majority of cases, the formula works perfectly but occasionally it is throwing up "0" as the answer - even though there's no zeroes in column D.
Is there an error with the formula? Or, alternatively, is there another formula I can use to achieve the same outcome?
Thanks in advance! :)
Hi all, I have a problem with a formula with SUMIFS and INDIRECT.
I want to sum up the lines in the D column that does not have the "AL" in the B column.
The number of lines between the sum of the row where the formula is and D6 will increase and vary.
I get the error #VALUE!
The formula is:
=SUMIFS(D6:INDIRECT("R[-1]C";0);B6:INDIRECT("R[-1]C";0);"<>AL")
examples of my excel worksheet layout
The line above having the formula =SUM(D6:INDIRECT("R[-1]C",0)) works great
I think that the formula should work but it doesn't.
Anyone who can figure out what is wrong with the formula?
Thanks!
/martin
In the SUMIFS function, the criteria_range needs to be in a single column. In the INDIRECT function you are using an absolute start column with a relative end column which results in multiple columns. Need to use an absolute end column. For example, change...
=SUMIFS(D6:INDIRECT("R[-1]C";0);B6:INDIRECT("R[-1]C";0);"<>AL")
to...
=SUMIFS(D6:INDIRECT("R[-1]C";0);B6:INDIRECT("R[-1]C2";0);"<>AL")
I am working on a personal budget sheet in excel, and it's formatted based on my pay dates, to provide more drilled-down information. I have attached an example of it below for reference.
I would like to put a formula into J2, J3, and J4 which will take the data in cells C9:C26 and H9:H16, match it to the date in cells D2:D4, then subtract the expenses in D9:D26 and I9:I16 from E2, E3, and E4.
As you can see, I have just individually summed the cells; however, I would like a formula to be able to adjust as I change the value in cells C9:C26 and H9:H16.
I have found that I can do it with ONE cell, but not multiple or a range. This is the formula I used, and I cannot find a way to make it apply to the entire range of cells: =IF(C14=D3,E3-D14)
I've also tried: =IF(C9:C25=D3,E3-D9:D25) -- I know this formula doesn't work and why. I cannot figure out how to get column C to correspond with column D.
The Budget Sheet
You just need to use SumIf().
In cell J2, put this formula: =SumIf($C$9:$C$25,$I2,$D$9:$D$25)+SumIf($H$9:$H$25,$I2,$I$9:$I$25) and drag down the three cells.
With that, you can add E2-[formula] to subtract all that from E2. Or of course, just do e2-J2 instead. I think that should do what you're looking for. If it's not quite it, let me know and I can tweak.
If you plan to have more than 1 criteria go with SUMIFS
Yes, with S