If a cell's value is found on another column, how to return the cell's value from another column which is on same row with the synced cell? - excel

My Excel table is looking like this.
A column is the one that I want to fill in with correct data.
B column is where the lookup values are.
C column is the one where I want to extract data from.
D column is where data from B column will be searched.
For example, if data from B2 is found on D7 cell, I want to have in A2 the value from C7.
My Countries///My Codes////All Countries//////All Codes
AD Afghanistan AF
AU Albania AL
Algeria DZ
American Samoa AS
Andorra AD
Angola AO
Anguilla AI
Antarctica AQ
Antigua and Barbuda AG
Argentina AR
Armenia AM
Aruba AW
Australia AU
Austria AT
Azerbaijan AZ
It would be much appreciated your help because I would like to learn as much as I can about excel formulas.
Kind Regards,
Ioan

In A1 enter:
=INDEX(C$1:C$15,MATCH(B1,D$1:D$15,0))
and copy down:
Note:
MATCH() finds the row.INDEX() grabs the value.

Chris is right, looks like you need a vlookup, example
B1 would be
=Vlookup(A1,c1:d200,2,0)
B2 would be
=Vlookup(A2,c1:d200,2,0)
And so on
It works like this
Vlookup (value to lookup, range the lookup and return values are in, column number from range you want to return, exact match only (0 or false))
Though Chris's link is more detailed

Related

lookup values between date range

Good day,
I'm trying to use V&hLookup to get my values but I'm not sure if I'm using the correct formula.
I'm working of 2 sets of data (sheet1 and sheet2). Sheet1 the data is vertical (e.g. unique identifiers and dates) and sheet2 the dates are horizonal and values below. Both sheets have unique identifiers Vertically.
Question: On sheet1, I need to look up the values from sheet2, if there is not values then the formula must look at the next available value after the start date? I got the values as examples on sheet1 as to what it should be
E.g.
Sheet1
Key
Dates
Values
12345
01/01/2020
120.00
678910
01/02/2020
150.00
789456
01/03/2020
110.00
Sheet2
Key
01/01/2020
01/02/2020
03/04/2020
12345
120.00
0.00
150.00
678910
0.00
120.50
130.00
789456
160.00
120.00
110.00
Thanks a million.
Edited answer: suggested solution using MATCH(search_value,match_range,1) in combination with INDEX gave wrong results.
The following should do:
=INDEX(Sheet2!$A$1:$D$4,
MATCH(A5,Sheet2!$A$1:$A$4,0),
MATCH(
MIN(IF(Sheet2!$B$1:$D$1>=B5,Sheet2!$B$1:$D$1,"")),
Sheet2!$A$1:$D$1,
0))
Enter with ctrl+shift+enter in older Excel versions.
The row is found matching the Key-value and the column is found by matching the column where the date value in Sheet2 headers greater than or equal to search date value.
And when using Tables:
=INDEX(Table3,
MATCH([#Key],Table3[Key],0),
MATCH(
MIN(IFERROR(IF(--Table3[#Headers]>=[#Dates],--Table3[#Headers]),9^9)),
--Table3[#Headers],
0))
Where I needed to workaround the date headers becoming text instead of number values by adding leading -- to the value/range.

Sum Multiple values in different Rows using Vlookup Function

A B
France 152
Italy 255
France 221
Spain 215
USA 222
Spain 155
I desire to add each value occurring in front of repeating countries using Vlookup function
Solution:
A B
France 373
Spain 370
If you use a SUMIF then you can total the columns
If the data starts in cell A1 then in cell C2 type
=SUMIF(A:A,A3,B:B)
then drag the formula down. this will give totals for each country
Or if you just want to show the first instance (where it says France for example) then use
=IF(COUNTIF(A$1:A2,A2)=1,SUMIF(A:A,A2,B:B),"")
You won't be able to do it with a vlookup.
You could use a pivot table which might be easier and that is useful for this exact type of question.
To get the list of repeating countries enter the following formula in Cell D2
=IFERROR(INDEX($A$2:$A$7,MATCH(1,INDEX((COUNTIF($D$1:D1,$A$2:$A$7)=0)*(COUNTIF($A$2:$A$7,$A$2:$A$7)>1),0,0),0)),"")
Then to get sum of corresponding country, in Cell E2 enter
=SUMIF($A$2:$A$7,D2,$B$2:$B$7)
Drag/Copy formulas as required. See image for reference.

Excel Index Partial match

I have Sheet1 with column A listing every single country in alphabetical order..
A
1 Afghanistan<
2 Albania
3 Algeria
4 American Samoa
5 Andorra
----------
228 United Kingdom
229 United States
etc
I have Sheet2 column A with empty cells with adjacent cells in column B listing address details
A B
1 empty cell Unit 3, Road;London, United Kingdom
2 empty cell Building 1, Road, TX, United States
3 empty cell 8th floor, Business Park, India 1234
etc
What I would like to know is how can I obtain the country within the address details in sheet2 column B and place them in Sheet2 column A, based on a match on the list of countries in Sheet1 column A.
Part of the problem is there is no coherent method as to how to country is placed within the address; could be at the end or in the middle of the address.
I have tried various index match formulas with no luck
any help would be appreciated.
I tried it with the reference table being in A1:B7, and lookups being A10:B10 onwards down. The formula is for these cells. You can adjust it for Sheet1/2!.
Assuming your data is in B10 onwards, and your reference data was in B1:B7, you can write this formula in A10 =INDEX($B$1:$B$7,MAX(IF(ISERROR(FIND($B$1:$B$7,B10)),-1,1)*(ROW($B$1:$B$7)-ROW($B$1)+1))). This is an array formula, so please hit Ctrl+Shift+Enter for excel to read it as an array formula.
(In the screenshot, I have pasted the table in A10:B12 as values only in D10:E12)
Text to Columns with a comma delimiter

Formula to Get data for a specific date

Date Time Country Desc
16/04/14 8.30 am India abcd
16/04/14 9.30 am India pqrs
17/04/14 9.30 am India xyz
17/04/14 10.30 am India abcd
I wish to get all the data of 16/04/14 in another sheet using formula. Vlookup takes only the first row data as reference is 16/04/14. Is there any other way to get data.
Try this then:
Assuming you have this data in Sheet1:
And you want to get all matches of dates in Sheet2 like this:
What you need to do is use this formula:
=IFERROR(INDEX(Sheet1!A$1:A$5,SMALL((IF(Sheet1!$A$1:$A$5=$E$1,ROW(Sheet1!A$1:A$5))),ROW($A1)),1),"")
Above is an Array Formula entered by pressing Ctrl+Shift+Enter.
Enter it in A2 then copy on the remaining cells.
For our example, I copied it until Row 10 (A2:D10).
Then you just need to type in the value you want displayed in E1 as shown in the picture.
Then all the columns will populate with the data that you need.
Hope this helps.
Important: The ranges in the formula needs to be adjusted to suit your needs.

Excel Find Nth Instance of Multiple Criteria

I have 3 columns of data. Col A contains Names, Col B contains a client ID, Col C contains a date.
I'm trying to figure out how to write a formula that will find the top 2 and top 3 instances of a specific Name in Col A and client ID in Col B and return the value in Col C.
Trying to avoid using VBA, but not sure if this is doable.
So for example data looks like this and I would want to return that Sam dealt with Client ABC the 2nd time around on 12/16.
Sam ABC 12/3
Adam XYZ 12/5
John DEF 12/9
Sam ABC 12/16
Adam HIJ 12/18
Assuming
your headers are in A1:C1
your data starts from A3 (yes, not A2)
You enter the name in G2 & Client ID in G3 & you want the list of
dates starting from G5
Enter these formula/values:
A2: =G2
B2: =G3
C2: =0
G5:
=IFERROR(INDEX(($A$2:$A$500=$G$2)*($B$2:$B$500=$G$3)*($C$2:C$500),MATCH(0,COUNTIF($G$4:G4,($A$2:$A$500=$G$2)*($B$2:$B$500=$G$3)*($C$2:C$500)),0)),"End")
(Formula in G5 is an array formula; confirm this with Ctrl+Shift+Enter)
Drag the formula in G5 down until you see 'End'
Value in cell G5 will always be 0 or '1/0' based on your formatting.
The list of dates corresponding to the name & client ID combination will start from G6.
Let me see if I understood your need. Correct me if I'm wrong.
You want to be able to inform a Name and a Client ID and have Excel tell you the last 3 occurrences of that combination?
By "top 2 and top 3 instances of a specific name" I'm assuming you mean the top 2 and 3 dates found for that specific name and ID.
If so, try this:
Supposing you have your example data table starting at Cell A1 and ending at Cell C6 (including column headers) and that you'll enter the name in F1 and Client ID on F2
A B C
1 Name Client ID Date
2 Sam ABC 12/3
3 Adam XYZ 12/5
4 John DEF 12/9
5 Sam ABC 12/16
6 Adam HIJ 12/18
Type this formula where you want to return the date of the last occurrence:
=IFERROR(LARGE(IF($A$2:$A$6=$F$1,IF($B$2:$B$6=$F$2,$C$2:$C$6)),1),"-")
This should be entered as an Array Formula, so don't forget to press CTRL + SHIFT + ENTER or it'll not work.
To bring the 2nd last occurrence on another cell, just copy and paste the formula and change the number 1 to 2 (as indicated below):
=IFERROR(LARGE(IF($A$2:$A$6=$F$1,IF($B$2:$B$6=$F$2,$C$2:$C$6)),2),"-")
If you typed 'Sam' on F1 and 'ABC' on F2, this formula would return '12/16' as the last occurrence, '12/3' as the 2nd last occurrence and a dash (-) as the 3rd last occurrence, since there isn't one.
Of course, you'll have to adjust the ranges and other cell references accordingly in your real data set.
Hope this helps.

Resources