Lookup Two Columns Against Two Columns in Excel - excel-formula

With two sheets, I'm looking to compare columns B and C from Sheet1 to columns A and B of Sheet2. If there is a match, record the value in column A from Sheet1 in column C of Sheet2.
Specifically, what would be a formula to place in Column C on Sheet2 to calculate the corresponding value from Column A on Sheet1?
Sheet1
| A | B | C |
| 1 | 1000 | A |
| 2 | 2000 | B |
| 3 | 3000 | C |
| 4 | 4000 | D |
Sheet2
| A | B | C |
| 3000 | C | |
| 2000 | B | |
| 3000 | C | |
| 1000 | A | |
Sheet2 (desired output)
| A | B | C |
| 3000 | C | 3 |
| 2000 | B | 2 |
| 3000 | C | 3 |
| 1000 | A | 1 |
Apologies if this particular issue has already been answered. I feel like this should be very simple, but I'm just not very experienced in these types of lookups.

The easiest way is to insert a helper column in each sheet that defines a unique key.
To do so, insert a new column C in each sheet and populate it with this formula =A1&";"&B1.
Then, enter this formula in D1 (formerly C1) of sheet 2: =VLOOKUP(C1,Sheet1!$C:$D,2,0)

Related

Index/Match with Varied Offset

Running into some trouble performing an Index/Match where the offset rows could be spaced 1 row apart, 2 rows apart, or 3 rows apart. Below is an example of the setup:
Sheet1:
| A | B | C | D | E | F |
-------------------------------------------------
| | | | | Apple | |
-------------------------------------------------
| Ser1 | | | | | |
-------------------------------------------------
| | | | | Orange| |
-------------------------------------------------
| Ser2 | | Ser3 | | Ser4 | |
-------------------------------------------------
| Ser5 | | | | | |
Sheet2:
| A |
---------
| Ser1 |
---------
| Ser2 |
---------
| Ser3 |
---------
| Ser4 |
---------
| Ser5 |
I have a list of the serial numbers (ser1, ser2, etc) in another sheet, and I need to match values in Column E where the correct value is above the serial number by 1, 2, or 3 rows. As you can see, serial numbers could be in column A, C, or E.
Ex: Ser1 should match on Apple. Ser2, Ser3, ser4, and Ser5 should match on Orange.
I can't seem to figure out the correct Index/Match that work completely since the offset at the end of the formula is either + or - by a static row number.
Rough solution:
In your sheet Make a structure like this:
| A | Row | Lookup
---------
| Ser1 |
---------
| Ser2 |
---------
| Ser3 |
---------
| Ser4 |
---------
| Ser5 |
For column Row put:
=SUMPRODUCT((Sheet1!A$1$:E$5$=A2)*ROW(Sheet1!A$1$:E$5$))
this will calculate row in which serial number occures in your data range. Then you may put in Lookup column:
=LOOKUP(2,(1/(INDEX(Sheet1!$E$1:$E$5,1,1):INDEX(Sheet1!$E$1:$E$5,B2-1,1)<>"")),Sheet1!$E$1:$E$5)
This formula will lookup for last non-empty cell in column E (please refer here for more comments) in range that is above selected serial number.
This is a partial solution as for "Ser5" you will receive "Ser4". To overcome that issue you may perform additional Vlookup on achieved results.

excel to count the duplicate in a column

I need to find the duplicates in this way.please help me
--|-----|-------|-------|-------|-------
| A | B | C | D | E |
--|-----|-------|-------|-------|------|
1 | 1 | a1 | 1 | | |
2 | 2 | a2 | 1 | | |
3 | 3 | a3 | 1 | | |
4 | 4 | a5 | 1 | | |
5 | 5 | a1 | 2 | | |
6 | 6 | a2 | 2 | | |
7 | 7 | a1 | 3 | | |
8 | 8 | a3 | 2 | | |
9 | 9 | a1 | 4 | | |
10| 10 | a1 | 5 | | |
----------------------------------------
For ex: Individual duplicate B column- In B column "a1" - 5 duplicate values totally,
check the c column i need the output like that
You should be using this formula in Column C
=COUNTIF($B$1:$B1,B1)
Let me know if it does not work.
You want a cumulative sum of the number of occurences of the value in column B. You can do that by inserting the following formula in C2:
=COUNTIF("$A$2:A2; A2)
You then drag in vertically, as far as you like. The result should be something like this:
| "C"
2 | =COUNTIF("$A$2:A2; A2)
3 | =COUNTIF("$A$2:A3; A3)
4 | =COUNTIF("$A$2:A4; A4)
And so on, and so on...
In column C kindly enter below formula.
=COUNTIF($C$1:C1,C1)
And drag it to last cell c10
Regards
Lalit.M

Kind of group by in Excel without VBA

I need another transformation help in Excel
| A | B |
---| ----|--------|
1 | ID | Course |
2 | 1 | A1 |
3 | 1 | A2 |
4 | 2 | A1 |
5 | 3 | A2 |
I want to have a kind of group by, i.e.
| A | B | C |D | ...
---| ----|---------|---------|---------|----
1 | ID | Course1 | Course2 | Course3 | ...
2 | 1 | A1 | A2 | | ...
3 | 2 | A1 | | | ...
4 | 3 | A2 | | | ...
Any ideas? Is it possible without VBA macro?
I believe that the following link on removing duplicates from column would suit your needs (in your case you would do it horizontally).
http://www.get-digital-help.com/2009/03/30/how-to-extract-a-unique-list-and-the-duplicates-in-excel-from-one-column/
Per your reply to Robert, if you want to do it without VBA, try this... Select all cells in the first column. Copy and paste them into the first column of another worksheet. Use Excel's Remove Duplicates function on the pasted data. Then use INDEX functions in the columns to the right in order to pull the first, second, etc values matching that first column value.

Excel - How to highlight duplicate values in their own row when values aren't adjacent

In my spreadsheet, I am trying to highlight duplicate values in a row.
Catch #1 is, every row is assessed differently.
Catch #2 is, the values are not adjacent in their rows.
Example:
A | B | C | D | E | F | G | H | I |
1 Bob | 1 | Jim | 2 | Pat | 3 | Sam | 4 | |
2 Bob | 3 | Pat | 1 | Sam | 1 | Jim | 2 | |
3 Jim | 2 | Bob | 2 | Pat | 3 | Sam | 2 | |
4 Pat | 3 | Pat | 3 | | | | | |
5 | | | | | | | | |
In the example, I am checking each row for duplicates in columns B, D, F and H. Basically the number columns are being assessed against each other.
Row 1: None are highlighted.
Row 2: D2 and F2 are highlighted
Row 3: B3, D3, H3 are highlighted
Row 4: B4 and D4 are highlighted, but F4 and H4 are not because they're empty. A4 and C4 aren't highlighted either because columns A, C, E and G aren't being checked.
Try this formula in conditional formatting's formula based rule:
=AND(ISNUMBER(A1), COUNTIF(1:1,A1)>1)
Hope this helps!

Comparing values conditionally

The data below is in an Excel sheet. The data is sorted on Column A (Cluster) and a group of values in Column B (Town) is associated with a Cluster. In the example below, the first five towns in Column B belong to Cluster A. Similarly, the next four towns belong to the Cluster M.
The requirement is that the first Town of each Cluster should be the same as the Cluster name itself. In the example below the first town of Cluster A is A so in Column C (Check), a 1 has been displayed. For Cluster M however, the first town is not M (it is N), hence Column C has 0 in it. Subsequently, in row 8, the cluster name matches with the town name. Hence a 1 is displayed in Column C.
How do I do this using either Excel Formulas or a macro?
+--------+---------+------+-------+
| Row No | Cluster | Town | Check |
+--------+---------+------+-------+
| 1 | A | A | 1 |
| 2 | A | B | |
| 3 | A | C | |
| 4 | A | D | |
| 5 | A | E | |
| 6 | M | N | 0 |
| 7 | M | O | |
| 8 | M | M | 1 |
| 9 | M | A | |
+--------+---------+------+-------+
With your columns labelled, in C2 and copied down to suit please try:
=IF(A2=B2,1,IF(A1<>A2,0,""))

Resources