问题
I want to find the value of corresponding clients PO # Invoice # Quote # etc.. & client list is mentioned in different multiple columns.
Formula used : =INDEX(D16,D17,2,MATCH('Client PO & Invoice Details'!A1:ACZ25,'Client PO & Invoice Details'!A1:ACZ1,0))
LOOKING FOR REQUIRED LOOKUP FUNCTIONS WITH MATCH OFFSET INDEX
回答1:
The staging of your data is really inefficient. If you made a client number column and expanded the data vertically rather than horizontally, you could really save yourself a lot of headaches. For example, if your data was organized that way you could use a pivot tabel to massively simplify this problem.
Barring changes to your data structure, you can do a vlookup for the date against an offset range:
=VLOOKUP($D$17,OFFSET('Client PO & Invoice Details'!$A$1,0,MATCH($D$16,'Client PO & Invoice Details'!$1:$1,0)-1,1048575,6),2,FALSE)
This formula should be placed in D18:D22 below the id and date filters. you will need to increment the vlookup index toward the end of the formula ( ...,2,FALSE)
to grab the specific column you are looking for. The 2 will need to be updated to 3,4,5, and 6 in the subsequent formulas to get each of the values.
First The formula finds your client number in row 1, next the offset defines a range 6 columns wide starting at the column that the client number was found in, lastly the vlookup works as usual by finding the date in the first column of the offset range and returning the value of the indexed column.
回答2:
INDEX(range you want to look in, how many rows down from the top of your range, how many columns to the right)
That is the basic usage for index. If the range is a single row or single column, then only the second entry is required and its how far down the range do you want to go. Another small caveat is if you 0 for # of rows or columns. 0 will make index return the entire corresponding row or column.
lets start by looking at what set of columns you want to be looking at. you need to match D16 (client#) with the appropriate entry in your header row. To do this, MATCH is a great choice.
=MATCH(value you are looking for, range you want to look in, and what type of match)
In your case
=MATCH($D$16,'Client PO & Invoice Details'!$1:$1,0)
$1:$1 is the entire 1st row of the spread sheet. The $ will keep the row number from changing if the formula was copied up/down to another cell. The 0 at the end tells the function you want an exact match, and not an approximate type match. After performing this function you will know what column to start looking in.
So now you need to figure out what row you want to work with and then start pulling the data. This could be down with a VLOOKUP. You could define your range using an OFFSET function. I am however going to take a different route. I am going to use MATCH again to determine the row we want to look at based on the column we determined
=INDEX('Client PO & Invoice Details'$A:$ACZ,0,MATCH($D$16,'Client PO & Invoice Details'!$1:$1,0))
This index is going to all rows in the column found with the match. So now we need to do a match in those results to figure out what row you are working with. In doing so we get a formula that looks like:
=MATCH($D$17,INDEX('Client PO & Invoice Details'$A:$ACZ,0,MATCH($D$16,'Client PO & Invoice Details'!$1:$1,0)),0)
Now that you know the row you are working with and the column(S) you are working with you can now extract the data you need using INDEX.
In D18 place the following formula
=INDEX('Client PO & Invoice Details'$A:$ACZ,MATCH($D$17,INDEX('Client PO & Invoice Details'$A:$ACZ,0,MATCH($D$16,'Clent PO & Invoice Details'!$1:$1,0)),0),MATCH($D$16,'Client PO & Invoice Details'!$1:$1,0)+1)
In D19 use the same formula but change the +1 to +2. keep doing that as you go down increasing the +# by one each time.
Based on the comment you will add columns as clients are added, you will need to adjust the formula each time a client is added. There are ways to automated this, but you are probably better off going the offset route in this case.
Be aware that you do have a limited number of column to group clients by.
来源:https://stackoverflow.com/questions/52345010/excel-match-offset-index-for-multiple-columns