Vlookup not working across sheets - excel

My intention is to lookup value in Date column in sheet 1, find matching date column in Sheet 2 then copy the date from Sheet 2 to Sheet 1.
Formula I am Using is --
=VLOOKUP(A2,2!A2:C3,1,FALSE)
but the result errors out in N?A value. Not sure what am I doing wrong?
1
+--------+--------+
| Date | Value |
+--------+--------+
|28/02/18| |
+--------+--------+
2
+--------+--------+---------------+
| Value | % |Date |
+--------+--------+---------------+
| 1000000| 20 | 28/02/18 |
+--------+--------+---------------+
| 2000000| 10 | 31/01/18 |
+--------+--------+---------------+
| 3000000| 30 | 29/12/17 |
+--------+--------+---------------+

VLOOKUP requires that the lookup column be on the left. Use INDEX/MATCH
=INDEX(2!A:A,MATCH(A2,2!C:C,0))

Related

Comparison of a column in Excel based on the result of other column comparison

spreadsheet 1 (2 columns)
|nmsid_prod | email_id_prod |
|-----------|---------------|
|5454 |abc#gmail.com |
|5454 |wqr#gmail.com |
|3444 |edf#gmail.com |
|3345 |ghj#gmail.com |
|3444 |ijk#gmail.com |
spreadsheet 2 (2 Columns)
|nmsid_contact | email_id_contact|
|--------------|-----------------|
|1234 | xyz#gmail.com |
|7890 | pqr#gmail.com |
|5454 | abc#gmail.com |
|3444 | edf#gmail.com |
if nmsid_prod(sheet1) is same as nmsid_contact (sheet 2) then it should compare email_id_prod(sheet 1) and email_ld_contact (sheet 2)
Output 1
|nmsid_prod | Email_id_comparision |
|-----------|----------------------|
|5454 | Match |
|3444 | Match |
Output 2
|nmsid_prod | Email_id_comparision|
|-----------|---------------------|
|5454 | Mismatch |
|3444 | Mismatch |
Need excel formula for o/p 1 and o/p2.
Tried with Vlookup and xlookup but not getting desired output...kindly help on the same
For illustrative purposes, the product data is distributed in the range A1:B6, while the contact data is distributed in the range E1:F5 (this is just for illustrative purposes and can be adjusted according to your needs).
To determine if there is a match, enter the following formula in cell C2 and copy it down accordingly:
=IF(SUMPRODUCT(($E$1:$E$5=A2)*($F$1:$F$5=B2))>0,"Match","Mismatch")
In essence, it is a simple SUMPRODUCT function that returns 1 (or a greater value if there are duplicates in the contact data) if there is a match based on ID and email, and 0 otherwise. The result of this function is wrapped in an IF function to return the text "Match"/"Mismatch".
The output and data used looks as follows:

Excel Macro to find a cell based on matching two values (Row/Column) and replace value in cell

I am having some trouble trying to find a solution to an issue I have. I have two excel sheets that I would like to find or index values from one sheet to the other and then replace the value of the cell after locating the cell.
I think maybe a better way to picture is that I have a excel sheet "Data1" that consists of three columns with rows of data.
Example of Sheet 1:
A B c
1 | Header 1 | Header 2 | Header 3 |
2 | -------- | -------------- |----------|
3 | 123456 | AABB |12AB12AB |
4 | 678910 | BBCC |34CD34CD |
I have a second Excel Sheet "Data2" that consists of multiple columns and rows of data.
Example Sheet "Data2":
A B C D E
1 | Header1 | BBCC | CCDD | AABB | EEFF |
2 | -------- | -----------|----------|---------|---------|
3 | 123456 | ValueX | ValueY | ValueZ | ValueB |
4 | 678910 | ValueXX | ValueXY | ValueYY | ValueZZ |
What I would like to do is run a macro:
To first, match the value A3 (123456) in Sheet "Data1" to the same value in Column A from Sheet "Data2"
Second, match the value B3 (AABB) in Sheet "Data1" to the same value in Row 1 from Sheet "Data2"
Third, replace the value in the corresponding cell with the value from Sheet "Data1" cell C3.
Then, Loop and replace all cells until the rows of data from Sheet "Data1" end.
The Values in Sheet "Data2" should then change to look like:
A B C D E
1 | Header1 | BBCC | CCDD | AABB | EEFF |
2 | -------- | -----------|----------|----------|---------|
3 | 123456 | ValueX | ValueY | 12AB12AB | ValueB |
4 | 678910 | 34CD34CD | ValueXY | ValueYY | ValueZZ |
Please let me know what you think and I hope I laid out the requirements as simple as possible. Thank you for your time and support to help me work this solution. Cheers
IF your version of Excel supports XLOOKUP then you can set up Sheet "Data3" with the same column and row headers and use this functions for the data cells.
=XLOOKUP($A3&B$1,Data1!$A$3:$A$4&Data1!$B$3:$B$4,Data1!$C$3:$C$4,Data2!B3)
It takes the data in data2 and overwrites it with the data from data1 if there is a match.
More on XLOOKUP

Excel formul to count Table Range using month from date text

I have an excel workbook where I am trying to count the number of apples in a named table. The workbook has multle sheets each named Jan, Feb, Mar, etc. with a corresponding table range of the same name.
My main worksheet has a list of months as columns and fruit as rows, I want to use a countif or suitable function to count the number of each fruit per month using the column heading as the worksheet portion of the formula.
This is what I have tried, this works, but has to be manually coded for each month, i would prefer it be more dynamic.
=COUNTIF(JAN[Labels],$A2)
Note: A2 contains the word apple
I have tried to get the month from the column date but it doesnt work
=COUNTIF(TEXT(E25,"mmm")[Labels],$A2)
This is roughly what the "master" table should look like (for clarity)
| | Jan-20 | Feb-20 | Mar-20 | .... |
| Apple | 4 | 3 | 5 | ... |
| Pear | 5 | 4 | 9 | ... |
EDIT:
Just to assist with anyone trying to help, this is roughly what a table on another sheet will look like:
| invoice | labels|
| 12535 | Apple |
| 12536 | Pear |
| 12537 | Apple |
This table would be a named table of Jan or Feb, etc.
Please try this:-
=COUNTIF(INDIRECT(TEXT(G2,"mmm")),"A")
G2 contains a proper date.
Here is a variation of the above where column 2 of the table is specified as the range to count in.
=COUNTIF(INDEX(INDIRECT(TEXT(G2,"mmm")),0,2),"B")
If you must use column captions to identify the column I would suggest MATCH to find it.
OK, so I found an answer, combining the above answer by Variatus with an additional new row.
| A | B | C | D |
1| | Jan-20 | Feb-20 | Mar-20 |
2| |JAN[Labels]|FEB[Labels]|MAR[Labels]| <- =UPPER(TEXT(B1,"MMM"))&"[Labels]"
3|Apple | 5 | 7 | 3 | <- =COUNTIF(INDIRECT(B$2),$A3)
4|Pear | 7 | 2 | 9 |
5|Orange| 1 | 3 | 3 |
So formula in B2 makes an uppercase text value of the month from B1 plus the column name Labels.
The formula in B3 (and down) counts the number of instances of the fruit from the named table & column shown in B2.

excel return the value of a cell based on two other values

What I'm trying to do is a little complex but I think it's doable in Excel.
I have two worksheets in a workbook on sheet one I have this...
| Code1 | Code2 | Code3 | Code4 |
| BA1 | xxxxx | xxxxx | |
| BA2 | xxxxx | xxxxx | |
| BA3 | xxxxx | xxxxx | |
And on the second sheet...
| CodeA | CodeB | CodeC | CodeD |
| BA1 | 1 | date | text |
| BA3 | 1 | date | text |
| BA1 | 2 | date | text |
| BA2 | 1 | date | text |
| BA1 | 3 | date | text |
| BA3 | 2 | date | text |
| BA2 | 2 | date | text |
What I want to do is lookup Code1 on sheet one and find it in the second sheet in CodeA then find the highest CodeB for CodeA and then concatenate CodeC and CodeD and place them on Sheet one in Code4.
I hope that makes sense, Thanks for any advice.
I think I understand. Does this look correct?
Sorry for the swedish formulas but it's an array formula that you add with CTRL+SHIFT+ENTER.
The formula in english is:
{=MAX(IF(Data=A2,CodeB;-1))}
And the named range Data is Column H and I, and CodeB is Column I.
If it does not find the value it returns -1
Sorry noticed now that I only did half of the job.
Make another named range called Table that spans column I to K (Code B -> Code D).
And in column code3 add this formula:
=Vlookup(B2,Table,2,false)
And in code4:
=Vlookup(B2,Table,3,false)
And you should get:
This should find the results you are looking for.
This is an array formula so you will need to press CTRL+SHIFT+ENTER once you have entered it into the formula bar, this will have to done for every formula you add to the column.
As it is an array formula I have only written it to reference rows 1 to 18, you will need to update all references to include you last row.
Columns titled CODE1(to 4) are on the first sheet (Sheet 1)
Columns titled CODEA(to D) are on the Second sheet (Sheet 2)
=CONCATENATE(VLOOKUP(CONCATENATE(A2,MAX(IF(Sheet2!A:A=A2,Sheet2!B:B,-1))), CHOOSE({1,2},Sheet2!A1:A18 & Sheet2!B1:B18, Sheet2!C1:C18 ),2,0)," ",VLOOKUP(CONCATENATE(A2,MAX(IF(Sheet2!A:A=A2,Sheet2!B:B,-1))), CHOOSE({1,2},Sheet2!A1:A18 & Sheet2!B1:B18, Sheet2!D1:D18 ),2,0))
If you do not require a space between the dates, just remove " ", from the middle of the formula.

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.

Resources