How to qualify cells to include in addition (Excel) - excel

I have a column of data that ranges from about 0-1500.
What I've been able to do so far is use the count function to create a table of how many of the data lie in certain ranges (0-50, 51-100, 101-500, etc)
How could I instead sum up the numbers in each column which are part of the above subgroups? Such as, the sum of all values between 0-50, the sum of all values between 51-100, etc.
I know some java, in which I would run a for loop with an if statement, but in excel I'm not sure how to use the if statement and apply it to a whole column.
Appreciate any advice.

Related

Excel automatically sort column of numbers

I am looking to automatically sort a column of numbers in descending order without touching the sort button, or VBA.
Unfortunately I am trying to achieve this in a work environment where I have no access to VBA and excel is not one of the latest versions that contains the new SORT function in 365.
It is quite literally a column of numbers, and the numbers are automatically updated as they are totals of rows of smaller numbers elsewhere, and these change based on something else - so this specific column will always change numbers, but I need the column to automatically keep on top of sorting numbers by descending order.
I tried using rank.eq and some other bits with adding a 1 to each row to avoid duplicates, but this buggered it up if more than two duplicates was found. Is there anything I can do at all? Even if it involves going a very long way round it and building extra tables and things etc.
Grateful for any help.
It'd be easier to see your data and without being able to use a spill range, it's impossible to know how many rows. I also think you're intending to use LARGE function rather than RANK.
If you had your numbers in column A, you could drag the following formula down the appropriate number of rows to get the numbers sorted... (starting in cell B1)
=LARGE(A$1:INDEX(A:A,COUNTA(A:A),1),ROW())
If you can get your numbers in a table, you could use a similar formula but the table would ensure the appropriate rows exist (assume table name is Table1 and note the column names of RawNumbers and Sorted). Put this in Sorted Column:
=LARGE([RawNumbers],ROW()-ROW(Table1[[#Headers],[Sorted]]))
I presume using a pivot table is not a viable option... but these are how you could accomplish your objective of sorting by formula.

Dynamic named range including rows and columns

Little help needed here with excel dynamic named ranges.
I know how to make a dynamic named range that adjusts row height depending on the size of the range (no. rows with data in):
=OFFSET(Helper!$DJ$3,0,0,SUM(--(Helper!$DJ$3:$DJ$30<>"")))
However I find myself working with a large(ish) range of data across multiple columns - about 100 - and I REALLY want to avoid making 100 named ranges.
It must be possible to create a single named range that references the whole data set (DJ3:HE30) and the formula dynamically chooses which column to look at and (as before) chooses how many rows to return in that specific column.
The closest I've got is this:
=OFFSET(Helper!$DJ$3,0,0,SUM(--(Helper!$DJ$3:$DJ$30<>"")),SUM(--(Helper!$DJ$3:$HE$3<>"")))
But this just goes to the last column with data in (which makes sense really as it's doing the same thing with columns as it is with rows).
I'm assuming I need to tweak the starting point of the offset ref and somehow pass that column to the rest of the formula.
These named ranges are going to be used for drop-downs so the first drop-down will be the criteria that needs to be passed on to the second drop-down (that will utilize this new funky named range).
For example - if my first drop-down uses criteria 1,2,3 etc - my second drop-down would need to display results like this:
Option 1 = A,B,C
Option 2 = D,E,F
Option 3 = G,H,I
So the lists containing the letters in this example are all in individual columns, so the dynamic range needs to identify which column to use to pull the right list.
Also, with the number of columns I think I need to make this an INDEX rather than an OFFSET.
Can anyone point me in the right direction?
Thanks in advance, much appreciated!
It looks like I have managed to solve this one myself.
What I have done is create 2 named ranges as helper cells - Range_Start and Range_End. These ranges are single cells that contain an ADDRESS ref using MATCH to pick out the start and end of the column I need.
I then pass these named ranges to the formula I showed in my question but using INDIRECT to convert the cells to addresses:
=INDIRECT(Range_Start):INDEX(INDIRECT(Range_Start):INDIRECT(Range_End),COUNTA(INDIRECT(Range_Start):INDIRECT(Range_End)))
Works like a dream :-)

Finding the sum of dates using first column value

So I am working in excel and have two columns, as shown below.
What I wish to do is to able to get the sum of yearly deadlines for A, B and C.
So that:
Get a sum of dates within Year 2020 for each Variable
Get a sum of dates within Month/Year for each specific A,B and C.
Currently, I have been using a long approach. I use a Vlookup for each row getting a filtered table for each Variable. Then using that I filter out Dates using combination of Countif and Countifs. But the problem with that approach is that I end up getting huge rows and table of data in the end increasing the file size.
I have also tried to use sumproduct() but I do not have numbers so I can not find a sum.
Is there a smart way of doing it using one formula?
Thank you.
Use SUMPRODUCT. For year/variable:
=SUMPRODUCT(($A$2:$A$13=E2)*(YEAR($B$2:$B$13)=$F$1))
for month/year/variable:
=SUMPRODUCT(($A$2:$A$13=$E2)*(YEAR($B$2:$B$13)=$F$1)*(MONTH($B$2:$B$13)=G$1))

Returning sum of column for filtered data, without filter

I'm trying to calculate the sum of a column (TSQFT in the screenshot) that is part of a data set, which would be filtered based on multiple criteria using cell references (see screenshot). I don't want to use excel's regular filter as it's a hassle to change the settings and I'd like it to be done in a more automated way.
I've tried {SUMIF} and {SUMIFS} but those do not work as a filter - i.e. for a row to be {TRUE}, the numbers have to be in the same order as that specified in the criteria list {5-7-2} (see screenshot).
Would much appreciate any help.
You can try something like this:
Make 3 column of =IF(OR(C3=$C$10;C3=$D$10;C3=$E$10);1;0) formulas, one more column for a sum of this 3 column and a sumif based of the sum values
if the sum is 3 then the value is good.
This maybe the worst solution for this but as long as it can help, it can be developed into something better.

How do you obtain an array of vlookup values without an extra column in Microsoft Excel?

I have a list and a lookup table. The list will be in column A and the lookup table will be in columns C and D. Each cell in column C contains text and is unique. Column D has a corresponding value for each element of column C. Column A contains an unsorted list with duplicates of the text from column C but nothing outside of column C. An easy example is shown below
What I ultimately want is an array that contains the corresponding values looked up from the table for all of column A. So in this example I want
{1,2,1,2,2,2,1,1,2}
I know this can be accomplished by using
=vlookup(B9,$C$1:$D$2,2,FALSE)
in each cell of column B and grab the column as an array {$B$1:$B$9}. However, I need to skip the middle man and omit having anything in another column as this needs to be performed on various lookup tables simultaneous but not connected, i.e. not a multiple lookup, I just need to look at the same list A under a different set of corresponding values D.
I'm at a complete loss, it seems so simple but I've been trying for hours and going in circles. I recall reading that you can't output vlookup to an array and I didn't have much luck trying to use match either.
If you want to continue to use VLOOKUP:
VLOOKUP(T(IF(1,+A1:A9)),C1:D2,2,0)
where T is employed here since the values in A1:A9 are text, not numeric (otherwise we would use instead N - a range containing mixed datatypes would require a different approach).
http://excelxor.com/2014/09/05/index-returning-an-array-of-values/
Regards
You can achieve your array with the following use of the INDEX function in its array form. Since your lookup table is in the same orientation as the values in A1:A9, you must TRANSPOSE A1:A9 to achieve the cyclic array processing.
As an array formula¹,
=INDEX((TRANSPOSE(A1:A9)=C1:C2)*(D1:D2), , )
This can be proved in a single cell by wrapping the array result in a SUM function which will total the elements of the array.
=SUM(INDEX((TRANSPOSE(A1:A9)=C1:C2)*(D1:D2), , ))
... which returns 14.
                      INDEX function in Array Form
¹ Array formulas need to be finalized with Ctrl+Shift+Enter↵. Once entered into the first cell correctly, they can be filled or copied down or right just like any other formula. Try and reduce your full-column references to ranges more closely representing the extents of your actual data. Array formulas chew up calculation cycles logarithmically so it is good practise to narrow the referenced ranges to a minimum. See Guidelines and examples of array formulas for more information.

Resources