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.)
Related
My SUMIFS formula criteria is based on a cell (say A1) that is data validated by list and changed via selection by user. If cell has data inside text or number by selection from drop down list, SUMIFS formula is considering that data as criteria to calculate the related sum. If criteria cell is left blank, I want formula to sum everything without any condition. My problem here; in criteria field of SUMIFS formula, I typed if condition like; SUMIFS(sum-range,criteria_range,IF(A1<>"",A1,"*")) but in this case excel considers only text values and do not include cells containing number. Briefly, if nothing selected in A1, I want SUMIFS formula to sum everything without any condition, numbers, texts and even blank cells. How can we proceed to do that?
EDIT:
Here an example for data and formula, what is expected is actually to disable criteria if one of selection is blank on left. Harun's suggestion works but if there is blank cell in criteria range, then in this case it won't consider those values in sum. For instance, if we select from left Phone/smart/touch, then how can we get "2" as output no matter what is in cri_range4 cells? Thanks
Example:
How about this solution? It basically ignores a missing entry in column C and evaluates only the other two. (Your example formula has a fourth criterium that isn't apparent in your list but the method can be extended for as many criteria as you might have.
=SUMPRODUCT((IF(LEN(C2),(INDEX(Lists,,1)=C2),TRUE))*(IF(LEN(C3),(INDEX(Lists,,2)=C3),TRUE))*(IF(LEN(C4),(INDEX(Lists,,3)=C4),TRUE))*SumRange)
For better readability I created a named range Lists which comprises your sample range E2:H10 while I named I2:I10 as SumRange'. INDEX(Lists,,1}` refers to the first column of the range. It's important that SumRange and Lists have the same number of rows.
If A1 is blank then just use not equal operator to sum all cells that are not blank. Try below.
=SUMIFS(D1:D5,C1:C5,IF(A1<>"",A1,"<>"))
Edit: can you check below formula in D3 cell then drag down.
=IF(C2="",SUM($I$2:$I$10),SUMPRODUCT(($E$2:$H$10=C2)*($I$2:$I$10)))
I have an excel sheet when I am trying to use SUMIF to add values based on the values of another range as below screenshot:
I am using the below SUMIF formula:
=SUMIF(B2:B560,"<=10000",A2:A560)
My target is to have the sum of cells in column A if their corresponding value in column B is less than or equal 10,000.
My issue is that excel ignores the blank cells while I need them to be counted as less than 10,000. I can't manually replace blank cells because it is a long sheet.
I appreciate your time and support.
One option is an additional SUMIF:
=SUMIF(B2:B560,"<=10000",A2:A560)+SUMIF(B2:B5260,"",A2:A560)
Another option is SUMPRODUCT:
=SUMPRODUCT(A2:A560*(B2:B560<=10000))
A third option, if you have access to the FILTER function:
=SUM(FILTER(A2:A560,B2:B560<=10000))
Example: I need to count the number of values in a range that are greater than 3, but I don't want to have to rewrite the formula every time the criteria number may change. So the criteria number is calculated in a reference cell. So, lets say, 3 is entered in cell A2. A formula should be countif(C:C,>A2). Excel does not seem to like the greater than used with a reference cell. Is there a work around?
You need to use:
=COUNTIF(C:C,">"&A2)
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
I have a range of cells that have different numbers. Each cell has another cell next to it which can contain OPEN or CLOSED. I only want to SUM the cells if their status cell says OPEN.
Here's an example of what the number and status looks like
Adjust for your own columns and ranges:
=SUMPRODUCT(--(B2:B10="OPEN")*(A2:A10))
You could also use SUMIF() or SUMIFS().
SUMIF is normally preferable for summing with a condition
=SUMIF(B:B,"Open",A:A)