Match corresponding records on different sheets - excel

For example: I have two sheets, both with matching columns, Column A and B are the same on both sheet. Column A on both sheets will always match, they will always contain the same value, but Column B may be different, like in the example bellow. All of the data matches besides row 3. In Sheet 1 it has "c" in column B, but in Sheet 2 it has "f" in column B.
What I am trying to do is have a column that shows if they match or not, so in the example, row 1, 2 and 4 would all have "match", but row 3 it would say "mismatch" and I am trying to have this all on a separate sheet (sheet 3).
I think Vlookup would be the best bet, but I have no idea where to start. Any help would be appreciated.
Sheet 1:
ColumnA | ColumnB
1 | a
2 | b
3 | c
4 | d
Sheet 2:
ColumnA |ColumnB
1 | a
2 | b
3 | f
4 | d
Sheet 3:
ColumnA |ColumnB
1 | match
2 | match
3 | mismatch
4 | match

If two lookup equal each other than match, otherwise no match, In B1 of Sheet3:
=IF(VLOOKUP(A1,Sheet1!A:B,2,FALSE)=VLOOKUP(A1,Sheet2!A:B,2,FALSE),"Match","Mismatch")
And copy down.

Related

Excel IF/THEN/VLOOKUP Nested Formula

I have two tabs in an excel file. Sheet 1 and Sheet 2. I have been working on a nested IF/THEN/OR/AND formula in excel that needs to do the following:
In Sheet 1, I need to make sure that two columns - Name 1 and Name 2 - match. If they do not match, I need to make sure that Name 2 matches to a Name column in Sheet 2.
Formula must - If Name 1 and Name 2 in Sheet 1 match, then YES, else NO. If NO, then VLOOKUP Name from Sheet 2 and Match with Name 2 in Sheet 1. If there is a match then display YES, else NO.
So far I have two separate columns that check for this. The first uses an exact statement to match the two name columns in sheet 1. The second does a vlookup to see if the name appears in the second sheet. I need this in one cell formula if possible and I am not sure how to do so without splitting.
+----------+----------+--+--+----------+
| Sheet 1 | | | | Sheet 2 |
+----------+----------+--+--+----------+
| Column 1 | Column 2 | | | Column 1 |
| Name 1 | Name 2 | | | Name |
+----------+----------+--+--+----------+
You will need to adjust the formula below for your sheet names and ranges, but this is a formula that will check column A against column B and if not the same, will check column B against a vlookup table. It also lets you know if there was not a match found in the vlookup table instead of just giving the error code #N/A
=IF(A3=B3,"Columns Match",IFERROR(VLOOKUP(B3,Sheet2!A4:B14,2,FALSE),"No Match Found In Vlookup"))

Index only cells in a column from another sheet if another cell in same row has a value greater than 0

So I have an example below of what I'm wanting to do.
Basically I need to Index Column B from Sheet 1 into Sheet 2 BUT ONLY if the values in Column W in Sheet 1 are greater than 0. If it's not then I don't want it to be included in. The only column to Index is B starting from row 5 to say 100. Same for Column W.
I was trying to do it myself as I found This which is very similar as what I'm wanting to do but I couldn't figure it out.
Sheet 1
Row# Column B | Column(s)… | Column W
=================================
5) Thing 1 | | 0
6) Thing 2 | | 3
7) Thing 3 | | 0
8) Thing 4 | | 1
Sheet 2
Row# Column B | Column C | Column D
=================================
5) Thing 2 | 3 |
6) Thing 4 | 1 |
7) | |
8) | |
EDIT #3
You can use either SMALL, LARGE function to return the values from Column B on your Sheet1.
Presume you have given the following names:
Sheet1ColB: Sheet1!B5:B100
Sheet1ColW: Sheet1!W5:W100
Here is the formula to be put in Cell B5 on your Sheet2. Please note it is an array formula so you need to press Ctrl+Shift+Enter to confirm.
{=IFERROR(INDEX(Sheet1ColB,SMALL(IF((Sheet1ColW>0)*(LEN(Sheet1ColW)>0),ROW(Sheet1ColW)),ROW()-4)-4),"")}
or
{=IFERROR(INDEX(Sheet1ColB,LARGE(IF((Sheet1ColW>0)*(LEN(Sheet1ColW)>0),ROW(Sheet1ColW)),ROW()-4)-4),"")}
You can then use INDEX+MATCH to return the value from Column W on your Sheet1 in Column C on your Sheet2:
=IFERROR(INDEX(Sheet1ColW,MATCH(B5,Sheet1ColB,0)),"")
In the above screen-shot Solution 2 is using AGGREGATE which follows the same logic as SMALL/LARGE.
As you can see the sample data has taken into account duplicated values in Sheet 1 Col W, blank cells in both Column W and Column B on Sheet1, and blank cells, negative value or 0 value in Column B only on Sheet1.
Cheers :)
Use AGGREGATE() formula to filter based on condition.
=IFERROR(INDEX($A$5:$A$8,AGGREGATE(15,6,(ROW($A$5:$A$8)-ROW($A$4))/($B$5:$B$8>0),ROW(1:1))),"")

Excel function for comparing columns with repeated values

I'm using excel and have two columns (A & B) with values
I want to search for each value in Column A and return the position in Column B.
I'm using this formula:
IFERROR(MATCH("Values in Column A";"Array = Column B";0);0)
The results are:
Column A | Column B | Column C
1 | 4 | 2
2 | 1 | 3
3 | 2 | 4
4 | 1 | 1
1 | 2 | 2
| 3 |
It works fine if it doesn't encounter repeated values. However, I want it to encounter repeated values, so the formula should ignore the ones it was encountered before and go through the others. So the correct result should look like this:
Column C
2
3
5
1
4
Can you help me on this? Is there a VBA routine for this?
From the article Getting the 2nd matching value from a list using VLOOKUP formula, you can create a helper column to affix the instance number of each value, to create unique id's.
For example, in Column C, add the following function:
=A1&"-"&COUNTIF($A$1:A1,A1)
Note: The relative reference on the count range will cause the applicable range to grow as it is dragged down. The count of the items matching that cell in a range containing only that cell should always be one. As it gets dragged down to include other cells, it will increment accordingly.
Then add the same thing in Column D to get the instances of cells in Column B:
=B1&"-"&COUNTIF($B$1:B1,B1)
Finally, do the math you want to do in Column E like this:
=IFERROR(MATCH(C1,D:D,0),0)

Find two matching rows and display data from the thirt one (Excel)

So i have Two Sheets.
First sheet contains two columns
BRAND | LEFTOVER
The second sheet consists of two columns also.
BRAND | LEFTOVER (%)
So in case if the BRAND row value in the first Sheet will match the BRAND row value in the second i want to display the matching LEFTOVER (%) row value in the first sheet rows in the column LEFTOVER.
Kind of lost here.
Appreciate any ideas. Thanks.
In Sheet2:
. A | B
--------------------
1 BRAND | LEFTOVER %
2 X | Y
3 |
In Sheet1:
. A | B
--------------------
1 BRAND | LEFTOVER
2 X | =VLOOKUP(A2,Sheet2!A:B,2)
3 |
The VLookup function searches for its first parameter (in this case the value of Sheet1!A2) in the first column of the range denoted by the second parameter (in this case the leftmost column of the range containing columns A and B on Sheet2)
It then returns the value from that same row of the range that is to the right in the columns denoted by the third parameter (1 is the leftmost column where the matched value was). So in this case we use the number 2 because 1 means column A and 2 is column B (which explains why we used a two column wide range for the second parameter - it needed to encompass the column the result was in)
This isn't the only way to do this, but it is the easiest.
As Jerry stated VLOOKUP is the simplest way to do this.
HOWEVER if you have multiple/repeat instances (rows) in BRAND, VLOOKUP will only return the first record (row) that appears in your data.
If this is the case, you will need to add either a unique identifier column; and/or additional criteria to differentiate between the repeat instances.
As an example column A is used as a unique identifier to differentiate between the 2 'Nike' rows.
A B C
1 BRAND LEFTOVER
2 Nike 50
3 Adidas 25
4 Reebok 30
5 Nike 29
I feel that you can use vlookup to accomplish your goals.
Let me explain it in a bit detail.Suppose you have two sheets as:
A | B | A | B
--------------------- | -------------------
1 BRAND | LEFTOVER % | 1 BRAND | LEFTOVER
2 X | Y | 2 X | =Vlookup(A2,Sheet2!A:B,False)
3 | | 3 |
Sheet2 | Sheet1
After this you can drag this formula for the entire range. This will automatically make the formula correct for the below cells as well.
Also, if you need to populate any other fields from the Sheet2 then you can also use the vlookup as an array formula like: VLOOKUP(A2,Sheet2!A:B,{1,2,3,4},FALSE)
Enter this as an array formula using Crtl+Shift+Enter
Here {1,2,3,4} stands for the columns to be fetched.
If you want to know more about vlookup then read this article: http://www.exceltrick.com/formulas_macros/vlookup-in-excel

Excel COUNTIFS yields the same result with different criteria

I used the COUNTIFS formula and received the same result despite using different criteria. Below is a simplified scenario and here's a screenshot (sorry, newbies cannot post image).
Col A | Col B | Col C | Col D | Col E | Col F |
8/31/12 | Yes | Step 1 | 0 | 8/31/12 | blank | 8/31/12
8/31/12 | blank | blank | 10,000 |
8/31/12 | No | Step 5 | 0 |
The intended logic is as follows:
Criteria 1: include if column A matches "8/31/12" or cell F2
Criteria 2: include if column B is "Yes" or blank
Criteria 3: include if column C matches "Step 1"
Criteria 4: include if column D equals "0"
Here's are the two formulas that both resulted in the same answer (count = 1):
=COUNTIFS(A2:A4,F2,B2:B4,"Yes",C2:C4,"Step 1",D2:D4,0
=COUNTIFS(A2:A4,F2,B2:B4,"<>",C2:C4,"Step 1",D2:D4,0
Also, any suggestions on tweaking the formula to SUM column D if criteria 1-3 are met? Should I use SUMIFS? I think so but the argument structure is different.
Thanks!
=COUNTIFS(A2:A4,F2,B2:B4,"<>",C2:C4,"Step 1",D2:D4,0
should be
=COUNTIFS(A2:A4,F2,B2:B4,"",C2:C4,"Step 1",D2:D4,0
as "" will count blanks, not "<>" for CountIfs / SumIfs
SUMIFS would be
=SUMIFS(D2:D4,A2:A4,F2,B2:B4,"",C2:C4,"Step 1")

Resources