Matching and pulling values - excel

I've simplified a problem, where I have a sheet with 80,000+ rows and another sheet that is an index of sorts:
I need to structure a formula where, I need to pull the value in the second table, for a it would be 1 and so forth into the first table. I've tried:
=IF(VLOOKUP(A2, Table1, 1, 0), E2, "") but I get an #N/A error. I am not sure how to go about structuring this formula in a different way. I need to look up the value in the first Table, see if the value exists in the second table, and if it does, pull the corresponding value back into the first table

Assuming:
your first table is in A:B
your second table is in D:E
You can use this on B2 and drag:
=IFERROR(INDEX(E:E,MATCH(A2,D:D,0)),"")

Try:
=IFNA(VLOOKUP(A3,$I$3:$J$8,2,FALSE),"")
Results

Related

Index Match Formula Shows Wrong Result

I have two table, this one is the initial table that contains raw data (on Sheet 2)
And the second table (on Sheet 1) contains formula based on data from first table
I use this formula to calculate the data, but as we can see on the picture, it doesn't produce right result. Could you please help me to modify the formula?
=IFERROR(INDEX(Sheet2!$E$2:$E$12,MATCH(Sheet1!$B$1&Sheet1!B$2&Sheet1!$A3,Sheet2!$C$2:$C$12&Sheet2!$B$2:$B$12&Sheet2!$D$2:$D$12,0)),"")
First the auxiliar column, using the concatenate operator & :
Then the formula would be:
=VLOOKUP(B$2&$E$1&$A3;Sheet2!$A:$G;6;0)
Change 6 for 7 if you want the description instead of Activity.
Please try this formula. It should go into cell Sheet1!B3 where it must be confirmed with Ctl+Shift+Enter because it's an array formula. (017)
=IFERROR(INDEX(Table,MATCH(1,(INDEX(Table,,3)=$A$1)*(INDEX(Table,,2)=B$2)*(INDEX(Table,,4)=$A3),0),5),"")
In preparation of this formula to work you need to set up a named range by the name of "Table" which comprises of Sheet2!A2:Fxx. Better set this range up dynamically so that it expands as you add more data but you can also declare it as Sheet2!A2:F1000 where 1000 is a number of rows you expect never to need.
This table has 6 columns, A:F which I intentionally made to include column A, which you don't need so that range columns and sheet columns are identical. Table,,3 simply defines the 3rd column. You can replace it with Sheet2!$C$2:$C$1000. If you do, make sure that all your ranges have identical sizes.
The 5 near the end of the formula, at ,0),5),"") identifies the 5th column of the range Table from which the result is returned if the 3 criteria match. Change this number to 6 to return the result from column F or to 1 if you ever need the value from column A.

Why does this VLOOKUP result in an #N/A error?

Here is a simplified version. I was trying to match the shop grade from a given table to the data but it returned error, what's wrong with my vlookup function? I'm an Excel beginner.
The data:
The given table:
You are trying to match Column B so your lookup range should start with that:
=VLOOKUP(B2,Table!B2:C3,2,False)
Vlookup requires the first column to be the lookup column.
You have to look up by referencing the first column in the table. In this case, change B2 to A2 and it will work.
What is vlookup?
Does a lookup for a specified value in the left most column of a specified table(table_array) vertically from top to bottom and returns a value from one of the columns(column_index_number) of the table. Formula follows
VLOOKUP(lookup_value,table_array,column_index_number,[range_lookup])
These are common pitfalls with vlookup.
If table A is used to lookup and table B is getting populated with values
Lookup value is not first column of table array(table A)
Lookup column on table array is not sorted - sort using excel sort function in Data tab
Dragging the formula would have caused Table array to shift for each lookup in table B. E.g A1:C10 may become A2:C11 for second lookup and can result in #NA if lookup result falls in top rows which is missing. Use $A$1:$C$10 as lookup array table A to make sure that formula is not affected while dragging the cells. Alternately, naming table array can also be employed.
Range lookup true can result in getting invalid results even when no result is present in table A. Using range lookup false will be accurate in most cases.
Reference :
MS Office vlookup help
Named tables in Excel

Excel - Check if value X and value Y is on the same row

I have an excel document with two sheets, data and edu-plan. The sheet data has the following information:
The sheet edu-plan looks like this:
My question is: how do i create an excel formula that checks if the target group on the specific row in edu-plan! has the course name in question on the same row as the target group in sheet data!, i.e. if Sales and Sales course is on the same row in the sheet data!?
In reality, the data sheet as a couple of hundred rows and will change over time, so i am trying to develop a formula that i can apply easily on all rows/columns in edu-plan!.
The desired result in edu-plan would look like this:
A pivot table might be a good way to go.
If you would like to do it by formula, then you can just use a COUNTIFS
=IF(COUNTIFS(data!$A$2:$A$10,$A2,data!$B$2:$B$10,B$1),"X","")
A possible way to solve your issue with an array formula:
Write in B2 of sheet edu-plan
{=IFERROR(IF(MATCH('edu-plan'!$A2&'edu-plan'!B$1,data!$A$2:$A$6&data!$B$2:$B$6,0)>0,"x",""),"")}
Since it is an array formula, you need to hit shift + ctr + enter.
Here is the formula broken down:
MATCH('edu-plan'!$A2&'edu-plan'!B$1,data!$A$2:$A$6&data!$B$2:$B$6,0)
checks whether the combination of row header and column header is in the data table. MATCH returns the index of the found combination. Since we are not interested in the location, we only ask IF(MATCH > 0, "x", "") to write an "x" if a match was found. If MATCH finds nothing, it returns an error, which is why we add an IFERROR(VALUE, "") around the construct.

setting a dynamic cell reference in excel

I have a sheet setup that calculates totals. Easy enough if the data is already there but not if adding new data. So what I would like to be able to do is to not specify a specific end cell for the sum formula but let it update as more columns are added.
How can I do this with =SUM(m4:m?)
Suppose you need totals for data in M4:M10.
To make just open-ended range, you can make lower limit "too far": =SUM(M4:M100000).
Alternatively you can make it as =SUM(M:M) - SUM(M1:M3)
But this is not applicable when you need to have totals value just below the set of values. In this case you have 2 ways.
Using Excel embedded features
The formula will look like his: =SUM(M4:M10). If you insert a new row between M4 and M10 (for instance, select row 5, right-click, insert row), you formula will be automatically adjusted to =SUM(M4:M10).
The problem may happen if you want to insert a new value above the first row (select row 4, right-click, insert row) or below the last row (select row 11, right-click, insert row). In these cases totals formula will not be adjusted.
Possible workarounds:
For the "above first row" issue, I prefer to make some empty row above and hide it. In our case I would hide row 3 and make totals formula look like =SUM(M3:M10), so, when you insert a new row above the first row, in fact you insert a row to the middle of the table, and totals formula will be adjusted.
For the "below last row" - leave empty row below; but in this case you cannot hide it; just make it different color and make some remark like "new values shall be inserted ABOVE this line".
INDEX()
Interesting trick is using INDEX() function, which returns a reference to a cell in the array. For our case, the array can be the whole M row and, the index - row number.
For the "above first row" issue make totals formula like this =SUM(INDEX(M:M;4):M10). So, calculation will always start at row 4, even if some lines will be added/deleted.
"below last row". Suppose you have your "totals cell" in M13 and you want to have totals for all value between M4 and the "totals cell". The formula may look like =SUM(M4:INDEX(M:M;ROW(M13))) or, considering "above first row" case: =SUM(INDEX(M:M;4):INDEX(M:M;ROW(M13)))
Hope this helps
Sum(m4:m?) insinuates that you are looking to add more rows as opposed to adding column data.
If you want to auto sum a row data you can use something like:
=SUM(OFFSET(A1;0;0;COUNT(A:A);1))
However this assumes that the data is contiguous in each cell and also empties are not allowed for 0 because it gets the count wrong.
However: You could also define a table for the data range. If you add data to columns/rows that are in that data range, they will be included in the adjusted formula automatically - very nice indeed.
Select your data range, then Select Insert:Table. This will give your table a name like Table1.
Your sum function would now be adjusted to look something like:
=SUM(Table1)
Now, as you add to the range, the table resizes, and your function just works.
The beauty of using a table, is that if you add data to the row/column immediately after the table it resizes and includes that range. This is hard to do without a table. You can also change the format of the table, or make the format colours invisible but you're probably better off with some format to show the data area of the table to the user.
You can compute the last row containing a number using this formula:
=LOOKUP(2,1/ISNUMBER($J:$J),ROW($J:$J))
This formula would not have a problem if you had text or blanks in the range.
You could then define that formula as a Defined Name
and use the formula:
=SUM(OFFSET(J4,0,0,LastRow-3))
to Sum the range. Note the -3 at the end to compensate for the first cell being in row 4.
Another option would be to just set your range to a fixed range that you can guarantee will be larger than any range you might actually use:
=SUM(J4:J1000)
You can use a counta to find the max row number. Then pushing that into an indirect will give you the range you need.
=SUM(INDIRECT("A1:A" & COUNTA(A1:A1000000);TRUE))
Assumptions:
Data are on column A
Data start from first row
There are no blanks rows

Look up value, on another Excel sheet

I have a small list of names with no emails on sheet one, and on another sheet (sheet 2) I have the master list of names with their emails in the adjacent column.
I want to look up the email associated with the name from the master list (sheet 2), and place it on the first sheet.
Here is what the data looks like:
Sheet 1:
Sheet 2:
In the first sheet I tried to use VLOOKUP to match the name with the emails on the other sheet.
My equation was
=VLOOKUP(A8,Sheet1!A1:B285, 1, FALSE)
This ... did not work. Any idea on where to go from here?
Thanks.
Your formula is:
=VLOOKUP(A8,Sheet1!A1:B285, 1, FALSE)
If you take a look at VLOOKUP description, you will find the following description of the first parameter:
The value you want to lookup. The value you want to look up must be in the first column of the range of cells you specify in table-array.
So your formula tries to find name in email column.
One possible solution is to change the order of columns in the look up sheet and use:
=VLOOKUP(A8,Sheet2!A1:B285, 2, FALSE)
(make sure the sheet name is right, it is not clear what are the names of both sheets).
More universal solution is to use INDEX/MATCH combination:
=INDEX(Sheet2!$A$1:$A$285,MATCH(A8,Sheet2!$B$1:$B$285,0))
I think you have to put your equation like this:
=VLOOKUP(A8,Sheet2!A2:B285, 1, FALSE)
because in your equation you are making reference to the first sheet, I mean you want to find a value in the same table as you are searching.
I expect it will works. Let me know if it is wrong.
EDIT: When I put A2:B285 it's because I suppose that the table in your sheet2 it's the full table but instead of that you have to select all the table in sheet2.
VLOOKUP requires that the first column on Sheet2 is sorted in alphabetical order. Your formula (pointing at Sheet2!A2:B285) will probably work then!

Resources