I have an excel sheet, sheet1 which has 2 cols, A and B. Col A has some values and has corresponding mapping in col B(not all values in A have a mapping in B, some are empty). The sorting is done from Z-A and w.r.to Col A. I have another excel sheet, sheet2 which has similar Col A and Col B. Now, i want to find out whether any match is there between Col A of sheet1 and Col A of sheet2. If matches are found, those values should be copied onto a new column.
=VLOOKUP(Sheet1!L24,E24:F27,2)
I thought I might give a better explanation because i didn't feel any of these were useful for me to personally figure out VLOOKUP and this answer came up high on list of google when looking for VLOOKUP Examples.
Here is my example which is looking up data from one worksheet to another:
=VLOOKUP(I2,Sheet1!$A$2:$Q$338,2,FALSE)
which is:
=VLOOKUP(<NEEDLE>,<HAYSTACK>,<COLUMN OF HAYSTACK TO PULL BACK INTO LOOKUP COLUMN>,<LEAVE AS FALSE>)
Steps:
Select the column which is looked up as the <NEEDLE> eg lookup_value . This might be a list of cars
Then select the entire range of the data you want to search within as <HAYSTACK> eg table_array. This is simply a selection of a range of which data to search through. It can be range within the current worksheet, or a range on a different tab/worksheet
give a number which is index of column in the Haystack of which column you would like returned as the value. eg col_index_num
supply "false" as final paramater. this should always be false at least in the cases I've used it.
I hope that helps someone else.
It is possible to do a lot with Excel and ADO: Excel VBA to match and line up rows
Related
I tried to look but I was unable to find this information anywhere on the site.
I am trying to return a selection of my data that fits a criteria in another cell.
I have a sheet (Sheet1) that has ALL my data in it (around 38000 rows) and I need to filter this on another sheet(Sheet2) for one of the columns in this data. For example, if I wanted to return all members that had a 7 in column P on Sheet1? and return all the columns that appeared in Sheet1 in Sheet2
So far I am trying the INDEX(array,MATCH()) way of working but this is only returning the first person that has a 7 in column P and not each individual member. And if I do it on a line by line basis, there will be gaps in the data where it doesn't match and want them all bunched to the top. (I hope that makes sense)
Sheet1 Sheet2
The results show in Sheet2 is using the following formula:
=INDEX(Sheet1!A:A,MATCH($B$1,Sheet1!I:I,0))
Is this something that can actually be achieved?
Please let me know if I am not clear in anything I have asked.
You're on the right track with INDEX, but you're also right that MATCH will only get you the first result. You need an array formula that will carry through the rows you want to retrieve. Here's a simple example:
To get this, select H2:J21 and enter this as an array formula (commit with Ctrl + Shift + Enter):
=IFERROR(INDEX(A2:C21,SMALL(IF(C2:C21=E2,ROW(A2:A21)-ROW(A1),FALSE),ROW(A2:A21)-ROW(A1)),COLUMN(A1:C1)),"")
UPDATE:
As #OverflowStacker points out, for your example problem, since your table headers are on row 1 and it doesn't look like you would ever have your column header in your lookup column's data, you could use a simpler formula:
=IFERROR(INDEX(A1:C21,SMALL(IF(C1:C21=E2,ROW(A1:A21),FALSE),ROW(A1:A21)),COLUMN(A1:C1)),"")
this is my first question so I will try my best to format this.
I would like to use the vlookup function in more than just one column. It seems impossible to do is in the formula for the large data set, so maybe someone with VBA knowledge can help me.
In my excel file I've two spreadsheets:
Sheet1 with one column "A" with 16868 different processes ID's.
Sheet2 with columns from "A" to "HX", where "A:HW" are different processes ID's (each column have different numbers of rows) and in "HX" column I have a region for the particular row of processes.
What I am trying to achieve is to do vloop for sheet1 column "A" that will look for each record in table sheet2 and return "HX" when found it.
In example:
I'm looking for "A2" cell in sheet1 in table_array sheet2 "A:HX". If found it then return cell in the same row but from column "HX". The trick here is when the looking value is not in the sheet2 column "A", then it should vlookup in column "B", then "C" and so on till "HW". There is an option where the looking value might not be in sheet2 at all and then the formula should return "0".
Is it possible to do this in VBA or excel formula?
Firstly, please NEVER use VLOOKUP. Ever.
An INDEX/MATCH combination is always better in every way. It is faster, more flexible and more robust as it does not break if you insert columns. It is also (arguably) easier to use as you do not need to count columns.
Anyway, back to the problem at hand. You can use an INDEX/SUMPRODUCT combination for this:
=INDEX(<range of return values>),SUMPRODUCT(--MAX((<range to search in>=<value to search for>)*ROW(<range to search in>)))-(ROW(<range to search in>)-1))
The SUMPRODUCT returns the last row number where the value is found.
The last bit -(ROW(<range to search in>)-1) is just to make the returned value relative to the searched range (rather than an absolute row number.
The INDEX is then uses this value to select a value from the HX column.
I am trying to lookup a table in one of my sheets. my table consists of three columns and an unlimited amount of rows.
My table can be seen here:
In my second sheet I wish to write a formula which searches all rows in the table and looks for an exact match in column A and column B, this means it must find the row where column a has a value of "jan" and in that same row the second column must have value "y". Should it find this match, it should return the value of column C.
I tried researching hlookup but that is for horizontal tables so i dont believe this would work. I looked into Vlookups also but that only allows one criteria search instead of looking for two matches.
Can anyone shed some light here please?
You can use index and match with multiple criteria
=INDEX($A$1:$C$1000, MATCH("Jan"&"y", $A$1:$A$1000&$B$1:$B$1000, 0),3)
press CTRL + SHIFT + ENTER when entering this formula.
Convert the range to a table (ctrl-t) and then use SUMIFS to search the table based on two criteria
=SUMIFS(Table1[Alteration],Table1[Month],"Jan",Table1[Products],"y")
This is saying "give me [Alteration] where [Month] = "Jan" and [Products] = 'y'...this returns 364.
You can point the criteria at separate cells containing your criteria.
Be aware that if there is more than one row with identical data (ie more than one row with both 'Jan' and 'y'), column C will be summed together.
The INDEX function has the syntax
INDEX(array, row_num_in_array, [column_num_in_array])
And MATCH returns in the index location of a logic match
MATCH(lookup_value, lookup_array, [match_type])
Combining the two is a flexible technique, and surprisingly powerful -- the logic in a match lookup_value can be a complex condition.
SIMPLEST CODE
Operate on the whole column
INDEX(C:C, MATCH("Jan"&"y", A:A&B:B, 0), 1)
nb./ A:A is excel code for "all of column A". You can instead use:
RESTRICTED CODE
Operates on a subset of the sheet.
INDEX($C$2:$C$1000, MATCH("Jan"&"y", $A$2:$A$1000&$B$2:$B$1000, 0), 1)
Note that you MUST use identical row length arrays (eg. rows 2:1000) or the formula will not work. MATCH only knows how many rows into its lookup_array it got, you need to ensure its rows match those in INDEX's array
PS. apologies this is close to the previous answer, but the details were too long for a comment.
PPS. I missed the clarifications to the first answer. That will work, but there is no need to use all three columns as the array in the INDEX function. You are only returning data from column C after all.
Sorry about the heading but im finding it hard to explain so ill give it my best shot.
Here is my problem
I have 3 cells: Lender, product and productID I have a vlookup that fills the lender and product cells just fine
However i want a way to bring back the productID back from another worksheet matching with lender and product.
For instance if call1 = newcastle and cell2 = 2 year fixed then cell3 = 422
I tried using a vlookup but doesnt seem to work, Any help on this would be greatly appreciated. Thanks
You can use Index and Match to perform a lookup with two criteria. Here is an example of one from http://blog.contextures.com/archives/2012/07/12/check-multiple-criteria-with-excel-index-and-match/
=INDEX($D$2:$D$10,MATCH(1,(A13=$B$2:$B$10)*(B13=$C$2:$C$10),0))
As mentioned on the site, it is an array formula so rather than just pressing enter when you use the formula, you need to hold Ctrl+Shift+Enter.
To break down how the formula is formatted:
=INDEX(a,MATCH(1,(b=c)*(d=e),0))
a = The whole range with all the data in it
b = The first criteria for the data to be filtered on
c = The range in which the first criteria needs to be searched
d = The second criteria for the data to be filtered on
e = The range in which the second criteria needs to be searched
Make sure that you use $ in the correct places as in the above example.
Another alternative to using combination of the MATCH and INDEX functions that some may find more straightforward is to first insert a column on your lookup table and concatenate the cobmination of columns you wish to search by.
=CONCATENATE(B8,C8)
Then you can still use the Vlookup function, but instead of only entering the one column to lookup on, you would combined them in the lookup so that the combination of them looks up to the combination of them on the lookup table.
=VLOOKUP(B3&C3,A9:D10,4,0)
Let's say that Newcastle is in A2 and 2 year fixed is in B2. It doesn't matter what worksheet they are on.In another worksheet named Data you have a table with a column of lenders in column X, products in column Y and product IDs in column Z. There are column labels in row 1 so the real data starts in row 2 and there are 2587 rows of data. In the first worksheet's C2 where you want the double lookup for a ProductID that matches Lende and Product try this formula.
=IFERROR(INDEX('Data'!$Z$2:$Z$9999, MIN(INDEX(ROW($1:$9998)+(('Data'!$X$2:$X$9999<>$A2)+('Data'!$Y$2:$Y$9999<>$B2))*1E99,,))), "no match")
Currently I have a huge formula in my excel sheet:
=SUM(SUMIF(INDIRECT(A9&"!$F:$F"),"working";INDIRECT(A9&"!$B:$B"))+SUMIF(INDIRECT(A9&"!$F:$F");"Open";INDIRECT(A9&"!$B:$B"))+SUMIF(INDIRECT(A9&"!$F:$F");"internal",INDIRECT(A9&"!$B:$B"))+(SUMIF(INDIRECT(A9&"!$F:$F"),"finished";INDIRECT(A9&"!$AP:$AP"))))
In A9 is the name of the excel sheet that the formula has to use. So for example in A3 there's '20140612', so it has to use the excel sheet with the name '20140612'. Furthermore it sums up some values depending on some conditions.
My question is: I would like to direct the columns in the other sheets by their headlines, not their positions in the sheet. So for example le column AP doesn't always has to be in the position AP, but has always the headline 'Points'.
Can you think of an adaption of the formula that can direct the column by their headline?
I though of the MATCH formula. But I'm not to sure where I have to put this in.
I think the simplest answer would be to use named ranges within your sheet. In this way you could name a range (currently in column AP) as 'Points', change your formula to use 'Points' instead of '$AP:$AP' & if you move your points data about the formulas would be unchanged.
If you are planning to keep changing your header row values then you could use HLOOKUP to match up the header column probably in conjunction with MATCH & INDEX.
To answer your question about the usage of MATCH(), it's worth thinking of it as half of a VLOOKUP() or HLOOKUP(), i.e. it's the bit that finds the row or column containing the value you're searching for, then you can use INDEX() to get that row / column from a range you specify.
So, if you know that one of your column headings is "Points", then you could find it by using:
=MATCH("Points", A1:Z1, FALSE)
...which would return 10 if "Points" were the heading of column J for example. If you wanted to then use that column for a lookup, you can use OFFSET() to define that column as a range to use for a lookup, so let's say I wanted to find the text "foo" in the "Points" column, I could use:
=MATCH("foo", OFFSET(A1:Z1000, 0, MATCH("Points", A1:Z1, FALSE) - 1, 1000, 1), false)
... which uses the column index I found before as an input to OFFSET() in order to dynamically reference J1:J1000 and then search for "foo" in that column.
For your example in the question, rather than A1:Z1000 you could use a call to INDIRECT() that would return the entire range of interest from your source sheet.