Match on 2 cells and return value from 3rd cell (Excel 2013) - excel

I have 2 worksheets.
SHEET1 has numbers from 1-31 across Row 1. It has a list of cars in Column A (Ford, VW...).
SHEET2 has a list of cars in Column A, the day of the month in Column B and the condition in Column C (New, Used or Wreck).
I need to make a match on the car and the day of the month and then retrieve the condition.
For example:
SHEET2 has one row that shows:
Ford 8 New
SHEET1 shows at the intersection of Ford and 8 - "New".
Any help to resolve this is appreciated. I have looked at VLOOKUP, INDEX and MATCH until I am blue in the face, but I can't figure this one out! I also looked through this site and couldn't find any similar scenarios.
Thanks in advance.

The below works (based on a scaled-down version I set up based on your data.
Array formula is: =IFERROR(OFFSET($C$8,MATCH($A2&B$1,$A$9:$A$12&$B$9:$B$12,0),0),"")
For array formulas to work be sure to press Ctrl + Shift + Enter instead of just Enter when exiting edit mode.

Related

Excel look up value in array, return next value

I would like to look up a value in a range and return the value in the next row, but can't quite figure out how to do this. I especially would like to do this with formulas rather than VBA, and preferably with built-in formulas than custom (VBA) formulas, due to macro security issues.
I'm using Excel 2010. My workbook has two worksheets, "assessment" and "lookup". In lookup, I have lookup tables.
"lookup" looks something like:
Column A Column B Column C
1 Sales Engineering Manufacturing
2 Alice Bobbie Charlie
3 Dawn Edgar Frank
4 George Holly Isabel
In "assessment," I have some some drop downs from which users select one name from each column in "lookup." Based on some other criteria, I then rank these and create a new, sorted list (using INDEX() and MATCH()) that produce the selected name and corresponding column name a new sort order
Column A Column B
10 Engineering Edgar
11 Sales Alice
What I'd like is to return the name from the next row.
Column C
10 Holly
11 Dawn
But I'm having real trouble figuring out how to get there.
Assuming lookups is located at B2:D5 (change as required) and the result data is at F2:H3 (change as required) enter this formula in cell H2 then copy down.
=INDEX(
INDEX($B$2:$D$5,0,MATCH($F2,$B$2:$D$2,0)),
1+MATCH($G2,
INDEX($B$2:$D$5,0,MATCH($F2,$B$2:$D$2,0)),0))

Excel, How to write a formula that fits these criteria

A B C D E F G
1 Date: 9/15/2016 9/16/2016 9/17/2016 9/18/2016 9/19/2016 9/20/2016
2 Points: 0.5 1 - - 0.5 1
The above data is on tab 1 of an excel spread sheet
And below are fields on tab 2 of the same excel spread sheet:
A B
1 DATE: Points
2
3
4
5
I am trying to write a formula that will go through the dates and points rows on tab 1 and when it finds a date with a corresponding point it will populate that date in tab 2 under the Date column. Simple enough right? Well here's where I'm running into problems, I need a formula to include the following criteria:
1) If the date does not have a corresponding point in the second row on tab 1 it will skip it and move on to the next date to validate it and so on
*note- I also need the Points column on tab 2 to populate with the corresponding date, but I believe a simple HLOOKUP formula will work just fine
2) I would like to have the formula to where it can be duplicated on tab 2 cells A3,A4,A5 and so on, but as an example: if A2 has date of 9/15/2016, when the formula in A3 is checking for dates with corresponding points in tab 1, it will skip the date in tab 2 located in A2 since it's already been used
Below is a picture of the above data in case it didn't come out right, and thanks for the help!!
Use this array formula:
=IFERROR(INDEX('Tab1'!$B$1:$G$1,MATCH(1,('Tab1'!$B$2:$G$2<>"")*(COUNTIF($A$1:A1,'Tab1'!$B$1:$G$1)=0),0)),"")
Being an array formula it needs to be confirmed with Ctrl-Shift-Enter when exiting edit mode instead of Enter. If done correctly then Excel will put {} around the formula.
This will create a list as it is dragged/copied done. The list will be in the same order as the list on tab1.

Automatically working out the average of filtered results

I have a spreadsheet where column P has a score between 1-6
The cell O4 has the following formula: =AVERAGEIFS(P8:P5000,P8:P5000,"<>6",P8:P5000,"<>0")
This formula searches for the average of the score in column P excluding 6, blanks and 0
Column O has staff names e.g John, Mark, Tim.......
What i want to do is for Cell O4 to automatically calculate the average of the figures shown in column P after i have used the filter function to show only results of a selected staff member.
I was hoping excel might be able to do this automatically however cell O4 appears to still be showing the average of the whole column P regardless of whether i have filtered or not.
I was given the formula below on another forum but it seems to be giving slightly wrong results albeit only by a small amount but i need to have the results exact if possible. Any help appreciated.
=SUMPRODUCT(1-ISNUMBER(MATCH(P8:P100,{0,6},0)),SUBTOTAL(9,OFFSET(P8,ROW(P8:P100)-ROW(P8),0,1)))/SUMPRODUCT(1-ISNUMBER(MATCH(P8:P100,{0,6},0)),SUBTOTAL(2,OFFSET(P8,ROW(P8:P100)-ROW(P8),0,1)))
Maybe
{=AVERAGE(IF((P8:P5000<>6)*(P8:P5000<>0)*SUBTOTAL(103,INDIRECT("O"&ROW(8:5000))),P8:P5000))}
will do what you want. Assuming the Filter is on column O.
The 103 in SUBTOTAL will also exclude if rows are manually hidden. If this ist unwanted and it should only exclude hidden rows, if filtered, then use 3 instead.
This is an array formula. Input it into the cell without the curly brackets and then press [Ctrl]+[Shift]+[Enter] to create the array formula.
I would create a separate table in a new sheet with all unique staff members and then perform the calculation. This way, you can quickly compare values for all staff just by scanning the table instead of having to constantly update the filter to see the values for potentially dozens or hundreds of staff. You would add the staff name range and criteria to your AVERAGEIFS formula.
For your example:
Sheet 2
A B
--- ---
1 | Staff Average
2 | Bob =AVERAGEIFS(Sheet1!$P$8:$P$5000,Sheet1!$O$8:$O$5000,A2,Sheet1!$P$8:$P$5000,"<>6",Sheet1!$P$8:$P$5000,"<>0")
3 | Mary =AVERAGEIFS(Sheet1!$P$8:$P$5000,Sheet1!$O$8:$O$5000,A3,Sheet1!$P$8:$P$5000,"<>6",Sheet1!$P$8:$P$5000,"<>0")
4 | Joe =AVERAGEIFS(Sheet1!$P$8:$P$5000,Sheet1!$O$8:$O$5000,A4,Sheet1!$P$8:$P$5000,"<>6",Sheet1!$P$8:$P$5000,"<>0")

SUMIF statement returns a value from the incorrect row

My current formula on Worksheet1 is below:
SUMIF(Setup!$C$5:$C$375,"C-R",'PMS Input'!$K$13:$K$416)
On the Setup worksheet, I have confirmed that there is only one C-R in column C.
Row C39 C-R CAMPSITES
Row C40 G-S GROUP SHELTER
Row C41 G-S PICNIC SHELTER
Row C42 P-A SQUIRREL'S NEST
Row C43 P-A MISC. PARK REVENUE/VENDING
Row C44 P-A MINIATURE GOLF
Row C45 P-A CANOE RENTALS
Row C46 P-A BICYCLE RENTALS
Row C47 P-A PROGRAMMING FEES
Row C48 P-A MISC. PARK REVENUE/VENDING
On the PMS Input worksheet, the rows are as follows:
Row K48 CAMPSITES 9 18.25
Row K49 GROUP SHELTER - -
Row K50 PICNIC SHELTER - -
Row K51 SQUIRREL'S NEST - (195.00)
Row K55 BICYCLE RENTALS - -
Row K57 PROGRAMMING FEES - 108.00
Row K58 MISC. PARK REVENUE/VENDING - -
On Worksheet1, the value returned for the above formula looking for C-R is 0.
The actual responses should be C-R = 18.25. The incorrect response in consistent throughout the file.
I have three other locations using the same file, with no issues using the above formula.
Another formula issue:
=SUMIF($B$63:$D$82,"TIPS",R$63:R$82)
This formula is returning a value of 17, however there is no 17 in column R. The 17 is actually in column T. This same error is repeating on several other days.
I have compared, checked and re-checked the formulas, but to no avail.
Could this just be a problem with the overall worksheet, or have I been staring at my numbers too long?
On the second issue you need to know that SUMIF always works on a "one to one" basis. That means that both ranges need to be the same size and shape. If the second range isn't the same size and shape as the first then Excel implicitly makes it so, starting from the top left cell of range 2.
In short that means that with your formula like this:
=SUMIF($B$63:$D$82,"TIPS",R$63:R$82)
The sum range is extended to be the same size as the criteria range so that formula will do the same as this
=SUMIF($B$63:$D$82,"TIPS",R$63:T$82)
Note: second range covers 3 columns like the first. If any value in colums C and D are "TIPS" it will sum the relevant value from column S or T, so that's probably where your 17 comes from.
Can you explain in words what you are trying to do with this formula? Do you want to sum column R only if any value in B, C or D is equal to "TIPS" - what if all 3 cells are equal to "TIPS" in one row, do you want to sum column R 3 times for that row?
Your lookup and your values are not aligned correctly. C-R is on C39, and the value is on K48. They are 9 rows apart. However the lookup and values in your equation start eight rows apart.
So either you have an extra row in PMS or missing a row in Setup, or you just started at the wrong row and something like this would fix it:
SUMIF(Setup!$C$5:$C$375,"C-R",'PMS Input'!$K$14:$K$416)
SUMIF(Setup!$C$4:$C$375,"C-R",'PMS Input'!$K$13:$K$416)
to fix the second issue you'll need the following formula (based on the great detail provided by barry in his answer)
=SUMIF($B$63:$B$82,"TIPS",$R$63:$R$82)+SUMIF($C$63:$C$82,"TIPS",$R$63:$R$82)+SUMIF($D$63:$D$82,"TIPS",$R$63:$R$82)

Excel match and index to select value with 2 column and 1 row criteria

I'm trying to write a formula that can return a cell value using INDEX and MATCH but I can't make it work. I have the following setup:
year person pet friend sale
1 jeff scout matt computer
1 carole riley tom mouse
2 jeff sadi trung computer
2 carole daisy ellen mouse
Say I have three cells:
year 2
col person
sale mouse
RESULT: carole [year = 2, sale = mouse, column value from 'person']
Is there a way I can use index and match to zero in on the specific cell? I will always have a year and sale provided. However, the column (person, pet, or friend) will change so I need to find the value in that particular column where the year and mouse match the cells.
Once I get a formula to work I'm going to write a more general function, but I need help getting the INDEX/MATCH combo to work properly.
You could use a combination of Index and sumProduct:
=INDEX(Table1[[person]:[friend]],SUMPRODUCT(--(Table1[year]=J1)*--(Table1[sale]=J2)*ROW(Table1[[#Data],[year]]))-1,MATCH(J3,{"person","pet","friend"},0))
This would work as i
n the following example:
So J1 contains the year to look up, J2 contains the Sale name, and J3 is the column you want to return a value from.
Another option would to add a concatenated column to your table the has the values of year and sale:
you would then change the formula to:
=INDEX(Table1[[person]:[friend]],MATCH(K1&K2,Table1[Year&Sale],0),MATCH(K3,{"person","pet","friend"},0))
slightly shorter and defiantly faster.
NOTE: This might not work with versions of excel below 2010, if you are running an older version I can supply a modified answer.

Resources