Can a countifs range be dynamic?
I'm simply trying to do a countifs formula in a worksheet that is likely to grow, currently I have the upper bound set to 10000 but since I'm trying to count the number of instances a date appears in a list I have to have a countif formula for every single day of the year. Thats 365 countif formulas all with an upper bound of 10000 and I'm sure at some point in a few months I will have to update it.
Am I able to use Excel formulas much like I could in VBA to declare a dynamic range for my countifs function?
If you convert your cell range to a table (select your table then Insert > Table) you can refer to the entire column or row with your formula and it will adapt dynamically.
Related
I want to expand range of sum when new cells are added in down.
My first try was nesting counta function into range of sum function but it didn't work.
=SUM(I4&":I"&COUNTA(I:I))
Anyone has any idea about how to do it?
The shown solution does not work when there is an empty cell in the SUM range
It would be safer to just use:
=SUM(I:Ï)
to summarize the entire column.
If summing the entire column isn't possible I suggest to make an Excel Table column out of your data.
Excel Tables adjust automatically when new data is added. This is best practice.
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))
I'm searching for a way to link the range of an Excel table to a specific number.
Let's say I have a table that has a range of A1:B10. I want to make the number '10' dynamic and link it to a number that is calculated from another sheet. Let's say cell F1 contains that number and the value is '20'.
Is it possible to make a dynamic range so the table range changes to: A1:B(F1). Then my table would adapt automatically and this has to work in my file.
I prefer a formula instead of a macro in VBA, because I normally don't work with VBA.
An alternative is to use a dynamic named range which is what we used to do before tables. The range, enclosed by marching ants below, is defined as follows:
=OFFSET(Sheet3!$A$1,0,0,Sheet3!$F$1,5)
The top left cell is A1. It is as many rows deep as the number in F1 and 5 columns wide (which could also be made dynamic).
Yes, INDIRECT is your way to make any formula dynamic / dependent on other cell values.
Say you want to sum range A2:C2. But the value 2 for C is located in Cell G2.
=SUM(INDIRECT("A2"&":C"&G2))
this is equal to write =SUM(A2:C2) in my example below.
If you set G2 to 3 it would calculate A2:C3 for this =SUM(INDIRECT("A2"&":C"&G2)).
If you mean Excel table, I guess the answer is no with formula, probably with VBA.
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.)