I have a sheet in Excel where the columns contain different names of people that are in different teams in my department (i.e. Names in Column 1 are in Team 1).
For another sheet, I need to have a formula that achieves the following:If I write a name in Cell B2 that can be found in the first column of that other sheet (Team 1), Excel should populate cell B6 with "Team 1".
If instead, the name I wrote is found in the second column, then the text should read "Team 2".
I've tried a couple of different formulas w/o success, and stringing a lot of IF and OR functions together is way too cumbersome. Anybody has a better solution?
If you need this formula for more then only two column then id use the formula
=INDEX(Sheet1!C1:G1,SUMPRODUCT((Sheet1!C2:G6=B1)*COLUMN(Sheet1!C2:G6)))
Say you have a set-up like:
And in B1 of Sheet2 you enter Name3, you want it to return TEAM1 as shown below:
The only catch to this formula is that you will need to tell it how many columns are before your data so if you have a table more like:
Then you need to tell the formula that there are 2 rows before your data starts, your new formula will be
=INDEX(Sheet1!C1:G1,SUMPRODUCT((Sheet1!C2:G6=B1)*COLUMN(Sheet1!C2:G6))-2)
Notice the -2 before the last parenthesis this is to indicate that there are 2 columns BEFORE you data.
and the new result for looking up say NAME20 would become as follows:
*EXPLANATION: *
The formula works as follows , I will do it all on one page for easier viewing and instead of Sheet2!B2 and B6 I will use G2, and G6 on the same sheet as the data.
First we look at all values in the Range A1:E6 and find the one with the matching name so we use
=A1:E6=G2
Now when you enter this into the cell you will recieve a #VALUE,but if you goto the Formula Bar and press F9 it will shwo you the full value of the formula
{FALSE,FALSE,FALSE,FALSE,FALSE;FALSE,FALSE,FALSE,FALSE,FALSE;FALSE,FALSE,FALSE,FALSE,FALSE;FALSE,FALSE,TRUE,FALSE,FALSE;FALSE,FALSE,FALSE,FALSE,FALSE;FALSE,FALSE,FALSE,FALSE,FALSE}
In this we know that one cell contains the Name we searched for, this is represented by the TRUE
Now when using a formula like SUMPRODUCT, FALSE = 0 and TRUE = 1
So to get the column we mutiply every result by the column they are in.
=SUMPRODUCT((A1:E6=G2)*COLUMN(A1:E6))
So any cells that don't =G2 are FAlSE or 0, and when you multiply the column of that cell by 0 (because false = 0) it will simply result in 0. But for the one cell that IS TRUE or 1 When you multiply the column of that cell by 1 (because TRUE = 1) The product will be the cells column number
So as shown in the picture when looking for NAME13 the result of the sumproduct is 3 (its column)
Then to return the TEAM for that name, we use the INDEX function will return the value in a cell at the given cordinates.
In this case we want the value from A1:E1 that is in the same column as the Name we matched. When looked at as an Array A1:E1 looks like
{"TEAM1","TEAM2","TEAM3","TEAM4","TEAM5"}
And we want to return the value in that array at the same position as the column number of our cell, Minus any nonincluded column before the data, thus the reason for the -2 in the secon example I gave you.
So:
=INDEX(A1:E1,SUMPRODUCT((A1:E6=G2)*COLUMN(A1:E6)))
In this example excel interprets this formula as
Return the 3rd value (the 3 comes from the sumproduct as explained earlier) in the list of value from A1:E1. And that value would be TEAM3.
use a MATCH() or VLOOKUP() function inside an IF(). SOmthing like:
IF(NOT(ISERROR(MATCH(...)));"Team1";"")
Did you know you can browse functions by catergoty (such as Search), just clikc the fx left of your formula bar and use the drop down box. Each formula comes with a description with usually rather clear information...
Related
looking for some help speeding up sorting pages on a spreadsheet.
Currently we have 4 sheets absolutely packed with UK postcodes/zip codes.
At the moment we go into each sheet and sort the entire sheet to show the information for the specific postcode we enter. (Always returns one line of info each sheet)
Is it possible to just have a separate sheet where we enter the postcode it it finds the match from each sheet and displays 1 line from all 4 sheets? Hopefully that makes sense.
A idiot's guide tutorial would be great
So, let's say we have four sheets (sheet1, sheet2, sheet3 and sheet4). They all look like this:
Create your 5th sheet. Here, I'm calling it "lookup_here". You should look up how to use vlookup formulas as I'll fail to completely explain it here for lack of time. Basically, you are :
Looking up a value (such as 5F3322 postal code) in a table array
(such as sheet1 columns A, B, C and D.... keeping in mind that your
lookup value must be in the first column of the array)
Then returning the column index (like column B is 2, column C is 3, etc).
And finally stating if you want an exact match (false) or approximate
match (true). Almost always use false.
Here is what the final output would look like, and I'll put some sample formulas below the picture.
So, you'll input your postal code value in cell B1. Then you will have formulas in B3 through D6. It will take some time to build these.
B3 Formula: =VLOOKUP($B$1,Sheet1!$A:$D,2,FALSE)
B4 Formula: =VLOOKUP($B$1,Sheet2!$A:$D,2,FALSE)
B5 Formula: =VLOOKUP($B$1,Sheet3!$A:$D,2,FALSE)
B6 Formula: =VLOOKUP($B$1,Sheet4!$A:$D,2,FALSE)
Column C formulas are similar, but the 2 before false will be a 3.
Column D formulas are similar, but the 2 before false will be a 4.
I am using 2 spreadsheets. Sheet1 -Return Codes needs the values from Sheet 2- GL Interfaces. I am trying to match with column 1 on sheet 1 to sheet 2 in order to bring back the correct Name associated with an application ID.
The formula displays in the cell instead of the value replacing the formula:
=VLOOKUP(A2,'GL Interfaces'!A2:F61,2,False). What is wrong with my formula for this simple lookup?
I click in the column where I want the value to return to.
Click Formula | select Vlookup.
Click on A2 (the column with the application numbers) on sheet 1
Go to second sheet and highlight array that I want to be searched.
Put in 2 as a column with the Names (col index num) that I want to be searched on the second sheet
Enter False for the last entry (Range_Lookup)
Enter and only the formal displays in the cell I want a Name to appear.
What am I doing wrong?
=VLOOKUP(A2, 'GL Interfaces'!A2:F61, 2, false)
is a valid formula. make sure that the first column of the 2nd argument of vlookup is the one that contains the value from the first argument of vlookup. in other words: A2 needs to be found in A column of sheet GL Interfaces and if there is a row with a match, then return value from B column of GL Interfaces sheet
I am running into an issue in Excel when trying to create an automated spreadsheet. I have most of the data ready to go already, but this one thing is giving me some serious trouble.
I am trying to create a data tracking file. Most data will be entered manually, in which I will have certain data to be tracked (column A) and criteria to track that data for (row 1). The data to be tracked will always be the same, but the criteria will be changed depending on the needed numbers. The same sheet will contain multiple sets of this one table to track the same data over different time periods.
I would like to make entering the criteria for all tables easier, by having Excel automatically copy the contents of row 1 into the header rows of the other tables if data is present in row 1. If a cell is blank in row 1, I would like the corresponding cells in the other tables to also be blank.
I thought there was a way to do that, but I can't remember how. Also, I would like to achieve this without using macros.
I have been searching here and elsewhere online, but all I could find were ways to display pre-determined text or values, if a cell contains specific text, i.e. "if cell x contains apple, return TRUE in cell y" or "if cell x contains apple, sum value of cell y in cell z".
Example:
IF B1 =/= empty THEN B14=B1; IF B1=empty THEN B14=empty
Right now the only option I found was the formula =B1 in B14, but that returns a 0 if B1 does not contain anything, I would like to have B14 empty though in that case.
Is what I am trying to do at all possible, or am I remembering this wrong?
Any help would be really appreciated.
Try the following formula in cell B14:
=IF(B1<>"",B14,"")
The "" in the formula represents blank while <> represents 'is not equal to'. So IF B1 'is not equal to blank', THEN return B14. Otherwise (IF B1 'is equal to blank'), return blank.
You can as well reverse the TRUE/FALSE values of the IF by using:
=IF(B1="","",B14)
So this seems like it should be pretty easy. I could just concatenate and make another column in the data to make a unique combo and get my answer. But that just seems so messy. So here I am reaching out to you fine folks to pick your brains.
I want to look up HQLine and Description in the MPCC tab to return the correct MPCC Code. I tried a couple IF statements with VLOOKUPS but couldn't get it right.
So I need to look up BK3 Positive Crankcase Ventilation (PCV) Connector in the MPCC tab. So it needs to match BK3 and the Long description and then give me the correct code.
Here is the missing data file
Here is the MPCC export list that I want to search
Use SUMIFS.
SUMIFS will find the sum in a table of rows that meet certain criteria. If the MPCC is always a number, and the MQAb-LongDescription is always unique, SUMIFS will find the correct ID.
=SUMIFS(Sheet1!C$2:C$100,Sheet1!A$2:A$100,A2,Sheet1!B$2:B$100,B2)
where Sheet1!A$2:A$100 is the HQAb data, Sheet1!B$2:B$100 is the Long Description data, Sheet1!C$2:C$100 is the MPCC Number data, A2 is the HQLine, and B2 is the Description.
The formula would go in C1.
More information on VLookup with Multiple Criteria
You can use an Index/Match with multiple criteria.
I'm assuming that you will put this formula in "Sheet1", cell C2, and your lookup data is in a sheet called "Sheet2", columns A, B, C from row 2 to 30.
Put this in Sheet1, C2:
=INDEX(Sheet2!$C$2:$C$30,MATCH(A2&B2,Sheet2!$A$2:$A$30&Sheet2!$B$2:$B$30,0))
(Enter with CTRL+SHIFT+ENTER) and drag down.)
Adjust the ranges as necessary.
lets assume your first Table is on sheet 1 in the range A1:C11 and the MPCC codes are located on Sheet 2 in the range A1:C32. Each table has a header row so your data really starts in row 2.
Similar to BruceWayne's answer of using an array formula, you can bring the array calculation inside of a formula and avoid the special array treatment. There are a few functions that can do this. I will demonstrate with the SUMPRODUCT function;
On Sheet 1, Cell C2, use the following formula:
=INDEX('Sheet 2'!$C$1:C$32,SUMPRODUCT((A2='Sheet 2'!$A$2:A$32)*(B2='Sheet 2'!$B$2:B$32)*row('Sheet 2'!$A$2:A$32))
Explanation:
When the value in A2 matches the value in the range in the second sheet it will be true and false when it does not. when True False get used in math operations they are treated at 1 and 0 respectively. Therefore the only result from your two search criteria will be the rows where A2 match is true and B2 match is true and this will have a value of 1. The 1 will then be multiplied by the row number. Since all other results will be 0 since your list is a unique combination, the sum part of sumproduct will sum up to the row number where your unique row is located. This in turn is used by the indext function to return the row to give your unique number.
I have two different work sheets in excel with the same headings in in all the row 1 cells(a1 = id, b1 = name, c1 = price). My question is, is there a way to import data(like the name) from 1 worksheet to the other where the "id" is the same in both worksheets.
eg.
sheet 1 sheet2
ID Name Price ID Name Price
xyz Bag 20 abc 15
abc jacket 15 xyz 20
So is there a way to add the "Name" in sheet 1 the "Name" in sheet 2 where the "ID" in sheet 1 = "ID" in sheet 2?
Without coping and pasting of course
Thanks
VLookup
You can do it with a simple VLOOKUP formula. I've put the data in the same sheet, but you can also reference a different worksheet. For the price column just change the last value from 2 to 3, as you are referencing the third column of the matrix "A2:C4".
External Reference
To reference a cell of the same Workbook use the following pattern:
<Sheetname>!<Cell>
Example:
Table1!A1
To reference a cell of a different Workbook use this pattern:
[<Workbook_name>]<Sheetname>!<Cell>
Example:
[MyWorkbook]Table1!A1
Saw this thread while looking for something else and I know it is super old, but I wanted to add my 2 cents.
NEVER USE VLOOKUP. It's one of the worst performing formulas in excel. Use index match instead. It even works without sorting data, unless you have a -1 or 1 in the end of the match formula (explained more below)
Here is a link with the appropriate formulas.
The Sheet 2 formula would be this: =IF(A2="","",INDEX(Sheet1!B:B,MATCH($A2,Sheet1!$A:$A,0)))
IF(A2="","", means if A2 is blank, return a blank value
INDEX(Sheet1!B:B, is saying INDEX B:B where B:B is the data you want to return. IE the name column.
Match(A2, is saying to Match A2 which is the ID you want to return the Name for.
Sheet1!A:A, is saying you want to match A2 to the ID column in the previous sheet
,0)) is specifying you want an exact value. 0 means return an exact match to A2, -1 means return smallest value greater than or equal to A2, 1 means return the largest value that is less than or equal to A2. Keep in mind -1 and 1 have to be sorted.
More information on the Index/Match formula
Other fun facts: $ means absolute in a formula. So if you specify $B$1 when filling a formula down or over keeps that same value. If you over $B1, the B remains the same across the formula, but if you fill down, the 1 increases with the row count. Likewise, if you used B$1, filling to the right will increment the B, but keep the reference of row 1.
I also included the use of indirect in the second section. What indirect does is allow you to use the text of another cell in a formula. Since I created a named range sheet1!A:A = ID, sheet1!B:B = Name, and sheet1!C:C=Price, I can use the column name to have the exact same formula, but it uses the column heading to change the search criteria.
Good luck! Hope this helps.