Excel formula to select data range based on a condition - excel

I am trying to get the value from column A based on conditions below:
a) column number will be where the value match for (1101,1138,1554...) e.g: 1101 is column B
b) Row number will be where the number 1,2,3.. match in the column that came from condition (a) e.g-B:B

You can use a combination of INDEX-MATCH functions to find the value in column A:A with 2 parameters.
Breakdown of Formula:
=INDEX(A3:A7,
MATCH(L2,
INDEX(B3:G7,0,MATCH(K2,B2:G2,0)),0
)
)
The 1st line in the formula is your return range.
The 2nd line is the row to match the lookup on.
The 3rd line finds the column for the row lookup by using another INDEX-MATCH.
You'll have to modify the formula to suit your needs of course.

Related

I am checking to see if any values in column C match with values from column B

I need preferably a formula or macro in excel 2013 to do the following:
Check if any given values in column C match with values from column B.
If they do I want to take the corresponding value from the same row in column A as the matched items in column B.
I then want to take those values from column A and put them in the same rows in column D.
Specifically, I am checking to see if any ID's in column C match with ID's from column B. If they do I want to take the corresponding city ID from column A in the same row as the matched items in column B.
I then want to take those values from column A and put them in the same rows in column D.
I used this formula =VLOOKUP(C6; A2:B14; 1; FALSE) but it returns #N/A
VLOOKUP will always use the first column as lookup_array. But in your case, you are using the second column for lookup_array, and wanting to return the value in the first column. So VLOOKUP is not appropriate.
Depending on your version of Excel, you could use INDEX(MATCH or XLOOKUP:
=INDEX($A$2:$A$14,MATCH(C2,$B$2:$B$14,0))
=XLOOKUP(C2,$B$2:$B$14,$A$2:$A$14)

Need assistance me with this Excel Task? Unable to generate the proper results

Looking for help with this task. Here's is a portion of the table I'm working with:
What I'm trying to do is have the cells in Column B (MWD) return the value of the adjacent cells in Column C (Pseudo). Column A (Data Set) has the same values as Colum B but including duplicates. I need a formula where the duplicates in Column A will return the same value that it matches in column B.
Example: I need...
all the duplicate 1010001's to return pseudo 1
all the duplicate 1020001's to return pseudo 2
all the duplicate 1020002's to return pseudo 3
and so on...
I was trying to use index match function but don't know if I'm constructing the formula wrong or if it's the correct formula to use.
If data is sorted by column A, you can use one formula:
=IF(COUNTIF($A$1:A2,A2)>1,C1,C1+1)
if not, then other
=IF(COUNTIF($A$1:A2,A2)>1,INDEX($C$1:C2,MATCH(A2,$A$1:A2,0)),MAX($C$1:C1)+1)
in both cases copy the formula in second row (in C2 cell in my examples). To the first row add 1 manually.
First example:
Second example:

Lookup one cell in another sheet then return corresponding value

I have two sheets containing various columns in which two columns contains document number and prices. Now I want to match cell K3 (a document number ) of Sheet 1 within column D (all document numbers) of Sheet 2. If match exists, then i want the corresponding price mentioned in Column V to be returned.
This is the formula I've tried:
=VLOOKUP(K3,'Sheet1 (2)'!D2:D896,22,FALSE)
The VLOOKUP documentation is helpful here, especially points 2 and 3 which correspond to parts 2 and 3 of the formula.
The range where the lookup value is located. Remember that the lookup value should always be in the first column in the range for VLOOKUP to work correctly. For example, if your lookup value is in cell C2 then your range should start with C.
The column number in the range that contains the return value. For example, if you specify B2: D11 as the range, you should count B as the first column, C as the second, and so on.
So change the second D to V in your lookup range, and change the column to 19 instead of 22 - D is the 1st column, E the second and so on till V, the 19th column of the lookup range.
=VLOOKUP(K3,'Sheet1 (2)'!D2:V896,19,FALSE)
if VLOOKUP is not your thing, consider INDEX/MATCH.
=INDEX('Sheet1 (2)'!V:V,MATCH(K3,'Sheet1 (2)'!D:D,0))
=VLOOKUP(K3,Sheet1!D3:E8,2,FALSE)
In formula second last argument is the column number of values.

Using INDEX-MATCH to look for values in two columns and returning a third value

I am creating a matrix of sorts, where column A has a list of parts and the Row 1 is populated with weeks of the year in yyyy/mm format. What I am trying to do is populate this matrix with quantity data from an aggregate sheet, where the demand quantities for each part is listed by week of the year. In this aggregate sheet, column A lists the parts, column B lists the weeks, and column C lists the quantities.
I've been trying to write an =INDEX(MATCH(),MATCH()) type of formula in order to fetch the value of column C if the values from Columns A & B match the values in Column A and Row 1 respectively on the matrix sheet, but have been only getting #REF errors in return. At this point I need a second pair of eyes. Here is the formula:
=INDEX(MRP!$C$1:$C$6400,MATCH(A2,MRP!$A$2:$A$6400,0),MATCH(B1,MRP!$B$2:$B$6400,0))
Am I going about this the right way, or is another method needed instead?
Cell B2
=SUMIFS(MRP!$C:$C,MRP!$A:$A,Sheet1!$A3,MRP!$B:$B,Sheet1!B$1)
You can then copy these down and across.
You are getting the #REF error because you are out of range of the array you are trying to match. The index function takes two arguments and one optional argument.
INDEX(array, row_num, [column_num])
Looking at your formula,
=INDEX(MRP!$C$1:$C$6400,MATCH(A2,MRP!$A$2:$A$6400,0),MATCH(B1,MRP!$B$2:$B$6400,0))
MRP!$C$1:$C$6400 is the array to be matched
MATCH(A2,MRP!$A$2:$A$6400,0) gets the row number. Maybe it should be MATCH(A1....)?
MATCH(B1,MRP!$B$2:$B$6400,0) gets the column number.
But since your matching array only have one column, the column number from the match function is greater than 1, which is outside the range of the array.
If you need to match both values in column A and B, you can use this formula to match
=MATCH(lookup_value_1 & lookup_value_2, lookup_array_1 & lookup_array_2, match_type)
For you case, it would be
=MATCH(A1 & B1, MRP!$A$2:$A$6400 & MRP!$B$2:$B$6400, 0)
you'll need to commit your formula using Ctrl+Shift+Enter rather than just pressing Enter. This will get you the row number where both col A and B matches cell A1 and B1.
Finally, you can index it
=INDEX(MRP!$C$1:$C$6400,Result from above match,0)
I would use SUMIFS. Create a helper column in your second sheet with the month number in and then use
=SUMIFS(sheet2!column C, sheet 2!helper column, month(sheet1!A$1),sheet2! column A, sheet1!$A1)

Understanding the vlookup formula in Excel?

I have two lists in the spreadsheet and some of the names match and some do not.
I need a formula so that where the text matches it can assign the corresponding value.
For example: in B2 it would read a 0 or false because there is no Jimmy T. in the C column. However, in B3 the formula should work as if the text in A3 matches any text in the C column it assigns the corresponding D value that is directly to the right. So, in B3 the answer would be 47.33.
The ultimate goals is for the value in the B column to correspond with Column A the same way that column C corresponds with column D.
And where there is not a value for column A to have it read "False" in column B.
Type on B2:
=VLOOKUP(A2,$C$2:$D$7,2,FALSE)
then, drag the formula down to the other cells on column B. The vlookup formula has four arguments (see explanation below).
To have the word "False" appearing where no match is found upgrade to the following formula:
=IFERROR(VLOOKUP(A2,$C$2:$D$7,2,FALSE),"False")
This is a example about the above formula's output.
Basically, what the vlookup function does is:
to find a match for the specified cell (first formula argument),
given an array of values (second argument). The leftmost column in the array must have the values to be matched with the formula's first argument),
and if there is a match it returns the values from one specific column of this array (third formula argument). In the above example we want to return the second column of the specified array.
The last argument on the vlookup formula returns the value for an approximate match (TRUE) or for an exact match (FALSE).

Resources