Moving two MS Excel cells that depend on each other - excel

I have a table where I enter the qualification times manually Name and Timer. It calulates the Final Time automatically, but I want it to sort the Final Time and Name in the right side from the fastest to the slowest, as in the second image. I tried using VLOOKUP and INDEX, but didn't manage to get it. I need help finding the right formulas to Cells I$ and J$. I hope to get a answer from here.
Hope to get it like following:

Use this formula in your column J. Enter it in J3 and copy down. As you see, it refers to column H where it expects the numbers 1 and up. So, it will look for the smallest, second smallest etc values in the given range.
=SMALL($D$3:$D$6,H3)
In I3 please enter the formula below and copy down.
=INDEX($B$3:$B$6,MATCH(J3,$D$3:$D$6,0))
It looks for the value the SMALL function extracted and finds the matching name.

Related

Excel calculate SUM of differences when cell addresses are not fixed

In Excel I have a list of employees (see image) and I want to store their salary update history. For each salary update, I want to calculate the difference in their total salary. I'm unable to create a formula to calculate this and SUM() the updates per period for me.
The image below demonstrates my spreadsheet and the desired salary update total (I did calculations manually, bet need a formula for this). In reality, there will be a few dozens of employees, so the requirement for the formula is to be dynamic and not contain manual "+" for each row.
NOTE: For some people their salary can stay unchanged and there are not any values in some cells. It's the main challenge, since we have to find the value of the "previous salary" for an employee, because it's not necessary stored in the previous cell. Otherwise, I could have used a simple array formula, like:
{=SUM(G3:G6-H3:H6)}. But unfortunately, it does not work in this case (there can be no value in the H column, so we have to find where it actually is).
Also, the formula should work correctly with filtering: is some row is filtered out (person is inactive, see picture), this row/cell should be ignored.
Can anybody help me with this formula that I'm struggling with?
This will do what you ask, not my my best work.Column "I"is still =SUM. Remember to press Ctrl + shift + enter. Then drag the formula where you want it to apply.
{=IFERROR(IF(E3="",E3,E3-INDEX(F3:$I$3,MATCH(FALSE,ISBLANK(F3:$I$3),0)))
+IF(E4="",E4,E4-INDEX(F4:$I$4,MATCH(FALSE,ISBLANK(F4:$I$4),0)))
+IF(E5="",E5,E5-INDEX(F5:$I$5,MATCH(FALSE,ISBLANK(F5:$I$5),0)))
+IF(E6="",E6,E6-INDEX(F6:$I$6,MATCH(FALSE,ISBLANK(F6:$I$6),0)));SUM(E3:E6))}
This formula does give the same answers as yours on the test data as below, BUT it is making a very big assumption - that the last recorded salary is always the largest one.
=SUM(IF(D3:D6="",0,D3:D6-SUBTOTAL(4,OFFSET(E3,ROW(D3:D6)-ROW(D3),0,1,COLUMNS(E3:$J3)))))
Must be entered as an array formula using CtrlShiftEnter
If you want to ignore hidden rows, plz use the form of Subtotal that ignores hidden cells
=SUM(IF(D3:D6="",0,SUBTOTAL(104,OFFSET(D3,ROW(D3:D6)-ROW(D3),0,1,1))-SUBTOTAL(104,OFFSET(E3,ROW(D3:D6)-ROW(D3),0,1,COLUMNS(E3:$J3)))))

Excel: How do I sum cell values every nth colum

I have the following table:
and I'd like to have the total for each player but values are every 3 columns.
As you can see from the picture on the bottom part I wrote what manually I should enter.
For player 1
=SUM(D3;G3;J3...)
Player 2
=SUM(D4;G4;J4...)
and so on. What formula should I use to calculate automatically every 3 columns? I know how the MOD works but on the net I found too many examples each one using different methods and none worked so far. Can anyone help me please or point me to the right direction to understand how it works to get this data since I'll be using this a lot (get value from cell every nth column).
thanks
It looks like you should just be using SUMIFS here:
=SUMIFS(3:3,$2:$2,"TOT")
This will sum every value on row 3 (Player 1) where the value in row 2 is "TOT" (every 3rd column). Put this in cell B18 and just copy down in your column B.
Or, in case you change your column labels, you can refer to cell D2 instead of typing "TOT" in the formula:
=SUMIFS(3:3,$2:$2,$D$2)
Try this, it will total all the cells that occur every 3 columns beginning at column D. Z3 can be increased to any column you require:
=SUMPRODUCT((D3:Z3)*(MOD(COLUMN(D3:Z3)-1,3)=0))
The explanation on how it works can be found here (I advise you to bookmark this site for future references. They have many other helpful formulas and functions).
Applying this formula to your reality should be something like this for Player 1 (Not tested. Adjust the ranges as required):
=SUMPRODUCT(--(MOD(COLUMN(D3:Z3)-COLUMN(D3)+1,3)=0),D3:Z3)

Excel Function Return Max Two Values

I am looking to get some help with a function that I am sure is an option but I sadly have no clue on how to implement.
Basically, I'd like a formula to go from C21:C50 and look for the top two values. Based upon which two are the top, it would reference the name in B column and populate that value in the another cell (the cell the formula resides in)
If you look at the image, in the primary field, we'd have Steve. Secondary would be Alan.
Is this something anyone can help with? I simply am lost :(
Try
=INDEX($B$3:$B$7,MATCH(LARGE($C$3:$C$7,ROW(A1)),$C$3:$C$7,0))
with Bob in cell B3 and the "primary" formula in cell C9. Copy down to cell C10.
If dealing with integers, you can simply add +1/ROW([range]) to avoid doubles:
=INDEX($B$3:$B$7,MATCH(LARGE($C$3:$C$7+1/ROW($C$3:$C$7),ROW(A1)),$C$3:$C$7+1/ROW($C$3:$C$7),0))
This is an array-formula and must be confirmed with ctrl+shift+enter!
However, this may fail for numbers like 5.01 or 4.99. For that case just use it in combination with RANK.EQ:
=INDEX($B$3:$B$7,MATCH(LARGE(RANK.EQ($C$3:$C$7,$C$3:$C$7,1)+1/ROW($C$3:$C$7),ROW(A1)),RANK.EQ($C$3:$C$7,$C$3:$C$7,1)+1/ROW($C$3:$C$7),0))
This is an array-formula and must be confirmed with ctrl+shift+enter!
The steps as picture:
The first table shows the direct adding of 1/ROW which is used for LARGE and MATCH to get the row if doubles exist (so INDEX can pick the correct one)
The second table shows how the values get replaced by their rank with RANK.EQ and then are treated the same like the first table.
The third (grey) table shows, what would happen if the first formula is applied to the second table (to demonstrate how the ranks get messed up).
For Excel 2007 just replace the RANK.EQ($C$3:$C$7,$C$3:$C$7,1) with RANK($C$3:$C$7,$C$3:$C$7,1).
If you still have any questions, just ask :)

Dynamically sum row values based on column headers? - Excel

Need solutions for the queries posted in the below link,
http://www.mrexcel.com/forum/excel-questions/334740-dynamically-sum-row-values-based-column-headers.html
Having PersonWeek as separate column with sum of weeks should be displayed.
Quest: Dynamically sum row values based on column headers?
It is good form to re-post the question in its entirety on this site; nevertheless:
What you are looking for is relatively straight forward. There are a lot of ways to accomplish this but I suggest that you use combination of the 'Match' function and the the 'Offset' function. The Offset function creates a range based on a given start point, moving up/down / left/right as indicated, with a given height / width. For example:
=Offset(B2,1,2,3,4)
Indicates the range D3:G5. This is the range given by starting at cell B2, moving 1 row down and 2 columns to the right, and going for a total of 3 rows and 4 columns.
So the remaining point is to determine where to start and stop your offset.
First, the first field in your Offset function will be cell A1, as that is the top-left corner of your data table. To find how many rows to move down, you need to find what project you are referring to (I will assume that cell A6 is where you enter the project name that you care about, A7 is where you enter the first week you care about, and A8 is where you enter the last week you care about). To find how many rows to move down from A1, then, use Match:
=Match(A6, A2:A5,0)
To find how many columns to move to the right to find your first week, use Match again:
=Match(A7, B1:G1,0)
Assuming you only want to look at a single project, we know how high we want the range to be (1).
To find how wide we want the range to be, we need to know your ending week, less your starting week:
=(Match(A8,B1:G1,0)-Match(A7, B1:G1,0))
So the whole thing together will be:
=Offset(A1,Match(A6, A2:A5,0),Match(A7, B1:G1,0),1,Match(A8,B1:G1,0)-Match(A7, B1:G1,0))
Now the only thing left is to wrap the newly defined range in a 'sum' function, like so:
=Sum(Offset(A1,Match(A6, A2:A5,0),Match(A7, B1:G1,0),1,Match(A8,B1:G1,0)-Match(A7, B1:G1,0)))
This formula will create an error if someone enters a project name / weekname in a way that isn't found in your table - so in cells A6-A8 you may want to use data validation to only allow those names to be entered - let me know if you would like elaboration on that.

Using the 'Match' function in Excel to return a cell address

I have a list of numbers in a table that I would like to search for and bring back the cell reference of where that number resides. For example the data looks like:
A B C D
1 1 2 3 4
ok it doesn't come out very well as the first one is the row number and then each number below sits under each letter, so C1 would contain '3'....
If I wanted to return the reference number of C1 in a cell I am using the formula of =CELL("address",MATCH(AU14,C1:AG1)) but this just errors. I have tried to put an Index in there too, but I believe that index only works vertically so this bring back a #N/A result.
Can anyone assist as I've wasted too much time on this already! :)
You are indeed missing an INDEX. And INDEX works vertically, horizontally, or both depending on how it's called.
Here is a formula that works for the ranges in the pictures. Should be easy to modify.
Formula in C5
=CELL("address",INDEX(B2:F2,MATCH(C4,B2:F2,0)))
formula
results
To make CELL work you need a cell reference, e.g.
CELL("address",C1)
The trouble is that MATCH just gives you a number, not a cell reference.
Probably the easiest way is to use the ADDRESS function, so a first try might be
=ADDRESS(1,MATCH(AU14,C1:AG1,0)+2)
That would give you the right answer if AU14 contained 3, but isn't considered to be very good because it wouldn't update if you deleted/inserted rows or columns.
A better one would be
=ADDRESS(ROW(C1),MATCH(AU14,C1:AG1,0)+COLUMN(C1)-1)
Then you might want to put in some error handling for the case where it's not found
=IFERROR(ADDRESS(ROW(C1),MATCH(AU14,C1:AG1,0)+COLUMN(C1)-1),"Not found")

Resources