Range row number reference from another cell in Excel - excel

Edited: So I made the question more complicated. If I would like to do a 'what if ' analysis which requires to be able to refer the last row to sum from another cell to the sumif formula. How can I do that?

Just drop the row numbers from your formula and use the entire columns:
=SUMIF(A:A,">4",B:B)
The beauty is that SUMIF will disregard non-nmeric rows anyway.
To sum up and stop at a certiain row, you can use SUMIFS with ROW:
=SUMIFS(B:B,A:A,">4",C:C,"<" & D2)
Where D2 holds the row number using the formula =ROW(<CELL>), i.e: =ROW(A2) in cell C2:

Related

How to convert the data following into range on excel?

I have data like following:
If I want it to convert it into specific ranges like following:
How should I do it on excel?
As Foxfire And Burns And Burns has mentioned, it is best to use a PIVOT TABLES and then Group it by intervals of 50. Using Pivot Tables and then Group & Ungroup is pretty easy and highly suggested by all excel experts in this community.
However if you are looking to use a formula to create that range (RAFFLE TICKET) that's how its known, then you may try the formula mentioned below,
Formula used in cell A2
=(ROWS($A$2:A2)-1)*50&"-"&ROWS($A$2:A2)*50
And Fill Down!
For those using Excel 2021 & O365, may try this one as well
=SEQUENCE(11,,0,50)&"-"&SEQUENCE(11,,50,50)
Next to get the total counts you can use SUMPRODUCT FUNCTION, which creates an array of TRUE's & FALSE's & multiplies the same with the corresponding ranges accordingly, so the formula used in cell B2
=SUMPRODUCT(($E$2:$E$16>=--LEFT(A2,FIND("-",A2)-1))*($E$2:$E$16<=--RIGHT(A2,LEN(A2)-FIND("-",A2)))*$F$2:$F$16)
And Fill Down!
I suggest you to create the Dummy column (C column) which will contain the limits of your ranges. And then you will fill values into the D column thanks to this formula :
=C2 & "-" & C3
So the first value Total Count column can be filled with (in column E) :
=SUMIF(A$2:A$16;"<"& C3;B$2:B$16)-SUMIF(A$2:A$16;"<"&C2;B$2:B$16)
and then you can extend the formula through the other cells of the column.
This SUMIF() formula calculates values for range <50 minus values for range <0 (for Range 0-50). For Range 50-100, this formula will calculate the sum for range <100 minus sum for range <50, and so on..
The
Remark : Here the limits of the range are not considered for example if Valeur =50 the formula in Range column doen't count it. If you want to consider them in account, you can modify the values of the Dummy column to 0; 49.999999; or 50.000001 (left for you as an exercice :) ).
I would advise you to create a helper column, using a formula like =ROUNDDOWN(A1,0).
Once you have this (let's say in column "C"), you can sum your values using the basic =SUMIF() function, something like:
=SUMIF(C$1:C$8,3,B$1:B$8)
(This will sum the values of the cells from B1 to B8, in case the corresponding values in column "C" are equal to 3, which means that the values in column "A" are between 150 and 199.99....

How to exclude specific rows (based on a cell value) from this simple Excel formula calculating avarage price?

I am absolutly not into Excel. I have a cell containing this formula:
=SUM(D2:D33)/SUM(F2:F33)
I want to adapt this formula in the following way: it has to skip a row (do not take into consideration in the previous formula. so the D cell value is not summed and the F value is not summed) if the B cell value has "SELL" as value.
it represents something like this related to a cryptocurrency calculator:
The I2 cell contains the previous formula that calculate the average buying price. I want to exclude from this calculation the row representing a sell operation.
What can I do?
EDIT-1: tried with this formula but I am obtaining this error message:
=SUM(FILTER(D2:D6,B2:B6="BUY"))/SUM(FILTER(F2:F6,B2:B6="BUY"))
You can use SUMIF(). Try-
=SUMIF(B2:B6,"BUY",D2:D6)/SUMIF(B2:B6,"BUY",F2:F6)
Or SUMPRODUCT()
=SUMPRODUCT((D2:D6)*(B2:B6="BUY"))/SUMPRODUCT((F2:F6)*(B2:B6="BUY"))
Or FILTER() formula with Excel-365.
=SUM(FILTER(D2:D6,B2:B6="BUY"))/SUM(FILTER(F2:F6,B2:B6="BUY"))

Find the Last Cell Value of the 2nd Column Set for each 1st Column Cell in EXCEL

I have the following structured table in excel where 1000s of rows included.
I want to return the Last Cell Value of Column B for Each value in Column A.
For example:
For Cell A1 -> I want to return the Cell B5.
For Cell A6 -> I want to return the Cell B9.
I have tried with VLOOKUP, HLOOKUP, INDEX likewise so many formulas where I ended with more conflict situations. Can anyone please write down a Formula to give my requirement a life?
Array formula (Press Control + Shift + Enter while entering the formula) in cell C1 and copy it down.
=IF(A1="","",IFERROR(INDEX($A2:$B$20,MATCH(FALSE,ISBLANK($A2:$A$20),0)-1,2),LOOKUP(2,1/(B2:$B$20),B2:$B$20)))
if you don't mind using column C as a helper column you could use something like that:
If you won't use Array formula you can Use this solution:
like this image:
use column C as helper with this formula in first cell =OFFSET(A1;SUMPRODUCT(MAX(($A$1:$A1<>"")*(ROW($A$1:$A1))))-ROW(A1);0)
and use this formula in column D's first cell =IF(A1="";"";INDEX($B$1:$B$13;SUMPRODUCT(MAX((ROW($A$1:$A$13))*($C$1:$C$13=A1)))))
and copy fill-down to all cells.
Try this shorter, without helper column and non-array formula solution
In C1, formula copied down :
=IF(A1="","",INDEX(B1:B$9,MATCH(1,FREQUENCY(1,0+(A2:A$9<>"")),0)))

Use cells to fill in the filepath for a SUMPRODUCT formula?

I am creating a SUMPRODUCT formula with a nested SIGN formula which helps to set criteria for which I want figures to be pulled from (similar to SUMIF or SUMIFS). Is there a way to have part of the formula refer to a cell/column that has a string, which is used to make up the filepath?
See below the example code.
=SUMPRODUCT(SIGN((
'S:\Folder\[File.xlsm]Range-97-98'!$B$5:$N$5
=
B$7
))*((
'S:\Folder\[File.xlsm]Range-97-98'!$B$423:$N$423
)))
The worksheet "Range-97-98' as you can see is a short Year range. This is because the current row the Sumproduct formula is on is a row assigned for 1997-98 (cell A9 = "1997-98")
Is there a way to change that Worksheet in the filepath based on the trimmed cell value from A column? eg. A10 is "1998-99" therefore the SUMPRODUCT would be Range-98-99'!..., and A11 is "1999-00" and so on.

Sumif formula on row determined by a criteria within column

I have been trying to create a formula that decides whether a row matches a criteria, and then sums data in the row based on a second criteria. I have tried my luck with LOOKUP,VLOOKUP, HLOOKUP, and INDEX, but have not figured out a correct formula. The most common error I get back is #Value when the sum would take place.
Example:
Let's say that the formula is in Q2. The formula needs to be able to match up A123 with the row A-123-4 (A2) and then sumif the row as long as the cells in that row are within the proper month MONTH($B$11:$I$11)=1
What I made initially was this:
{=SUM(IF(MONTH($B$11:$I$11)=1,$B2:$I2,0))}
The problem is that both of these are tables, so if the information gets rearanged using a filter, the data shifts. How can I get the formula to determine which row is the proper row to sumif?
Use This in Q2 and copy over and down:
=SUMPRODUCT(INDEX($B:$I,MATCH(LEFT($P2) & "-" &MID($P2,2,LEN($P2)) & "*",$A:$A,0),0)*(MONTH($B$11:$I$11) = MONTH(Q$1)))

Resources