In one spreadsheet I have a list of emails only. In another spreadsheet I have a list of the emails but also names, organizations, etc.
I have some background in programming but not with manipulating Excel. What I would like to do in terms of pseudocode is look at each email address on a new line in the first document, test IF the second document has that email, and if so retrieve first, last name, organization, etc. from the second document, and paste it in the appropriate columns in the first column. If not, to highlight the entire row in green in the first document.
Is this possible? Your help is greatly appreciated!
This can be accomplished a couple of different ways, the easiest would be a vlookup(), but a caveat with respect to vlookup() and the arrangement of the sheet 2 Data: Anything you would return from sheet 2 must be to the right of your lookup value (email address in your case). Vlookup() will not return anything to the left.
Also, Excel cells don't put into other cells, but receive a value into the current cell. (Yes, you could write a VBA function to put a value into a cell, but that may be advanced considering your experience 'manipulating Excel')
Assuming your sheet 2:
A B C
John#xyz.com John Smith Big Company
And Sheet 1:
A B
John#xyz.com
Your psuedocode in sheet 1 would be:
vlookup(from col a, in sheet2 -columns A(1) thru C(last row), return the nth column, False - I want an exact match)
The vlookup expression is:
(again in Sheet 1 Col B -- return the company name
=vlookup(a1,sheet2!a1:c1,3, 0)
Here 3 refers to the 3rd column of sheet2.
If you need more information:
GOOGLE:
vlookup()
hlookup()
index(match())
This is normally handled using the vlookup() function. So you'd use the email from book1 as the lookup_value, the range containing the values in book 2 as the table_array, the column from book 2 containing the value you want to import as the col_index_num (so if book 2 has email, name, organization in that order, you'd use 2 to pull in the name), and false as the range_lookup argument, to get an exact match. Something like
+VLOOKUP(A1,[Book2.xlsm]Sheet1!$A$1:$B$3,2,FALSE)
This will leave a #N/A in cells that don't have a matching email in book 2. You could use conditional formatting to turn the row green by saying "Use a formula to determine which cells to format" and using =isna($b$1) as the formula for example.
Related
I am trying to figure out a formula to find the first non blank cell with data on a separate tab from where I need the value returned. I've tried the following formula but no luck: =INDEX(Sheet2!H:H,MATCH(1,Sheet2!A:A=Sheet1!A3)*Sheet2!H:H<>"",0)
On Sheet 1 under column "Value from Sheet 2" I need the value from Sheet 2 under column H that is not blank using Sheet 1's "Name" column as the reference, in this case value "123" is the first non blank cell for name "ABC" on Sheet 2.
Thank you
In your data above, =sheet2!A$3:A$6=A3 is going to return {true;false;false;true}.
Further, =NOT(ISBLANK(sheet2!H$3:H$6)) is going to return {false;true;true;true}.
Thus, =(sheet2!A$3:A$6=A3) * (NOT(ISBLANK(sheet2!H$3:H$6))) should get you the array {0;0;0;1}, which is what you want to lead you to desired cell.
=MATCH(1, (sheet2!A$3:A$6=A3) * (NOT(ISBLANK(sheet2!H$3:H$6)))) gets you the index to the first hit, which is 4, and using that as in index into H$3:H$6 gets you all the way home.
But I’d exploit the more useful features of XLOOKUP instead and I resort to index/match only when required—which is pretty rare now that XLOOKUP exists:
=XLOOKUP( 1, (sheet2!A$3:A$6=A3) *
(NOT(ISBLANK(sheet2!H$3:H$6)))), sheet2!H$3:H$6)
One fewer functions, AND it adds the ability to handle a not-found condition.
This all should still work if you just decided to use A:A and H:H as in your previous formula.
I'm working on a pretty big data set. It's got two sheets. The first one contains the name of one city and multiple ID numbers. The second sheet should be left alone/unedited (raw data). It contains multiple cities and multiple ID numbers (some of them are in the first sheet and some are not).
I want something like: if city in sheet 1 and ID number in sheet 1 is in sheet 2, then return "Ok". Preferably without any helper columns.
An example:
Sheet1
City ID Status,
Londen 12345 OK,
12346 OK,
Sheet 2
City ID,
Londen 12345,
Mumbai 12333,
Londen 12346,
I've tried something like
=INDEX(Sheet2!A:B,MATCH(B2,Sheet2!B:B,0),0)
But I have not figured out yet how to add another condition and add the "OK".
I thought of using VLOOKUP, but I got stuck there too since I don't want to use helper columns
Thanks in advance!
You can use SUMPRODUCT function to check if both criteria are met in your Sheet 1. i.e. City = Londen and ID is shown on Sheet 2.
In my solution I have named the City column in Sheet 2 as Master_City, and named the ID column in Sheet 2 as Master_ID.
Presume you have the city name in cell A2 on Sheet 1, and ID is listed in Column B, then you can use the following formula to get the result:
=IF(SUMPRODUCT((Master_City=$A$2)*(Master_ID=B2))>0,"Ok","No Match")
Please note I have changed your example data a little bit to test the result. And I have set "No Match" for ID that is missing on Sheet 2. You can show a blank cell by replace "Na Match" in the formula with "" if needed.
You can read the following article regarding the use of SUMPRODUCT in varies situations to help to understand my answer better.
Master Excel’s SUMPRODUCT Formula
See below screenshot for more clarifications. Let me know if you still have any questions.
Cheers :)
I have an Excel workbook with 2 sheets.
I want to use Sheet 1 as the source to populate a column in Sheet 2.
Sheet 2, Column B has a list of resource names
Sheet 1, contains many of the same names in Column A, and a list of managers in Column F
I want to populate a separate column in Sheet 2 with the managers name from Sheet 1 based on matching the resource names.
I want to get a result of NOT FOUND if names don't match
I've tried
IFERROR(VLOOKUP(B8,'SHEET 1',!$A$3:$AR:100,6,FALSE),"NOT FOUND"), but this formula always returns "NOT FOUND" even though there are matches in Sheet 1
Looks like the ranges in your vlookup are a little wonky, e.g., 'SHEET 1',!$A$3:$AR:100
To be a little more straighforward, let's give you an index/match formula, so you can more easily specify the search array from the output array:
=IfError(Index(Sheets1!$B:$B,Match(Sheets2!B8,Sheets1!$A:$A,0)),"Not Found")
How this works is you Match() the cell on Sheets2! (B8 from your example formula) within the search array, Sheets1!$A:$A (yes, you can use a whole column which makes things a little easier). If nothing is matched, it throws an error (so if-error handles that); if it is found, then it will output (index) based on the output array, Sheets1!$B:$B.
You will want to fix the search array column and output array column to fit your scenario.
This is sort of a complex worded question, but I have created a sign-up sheet for my dorm's intramural teams, and the responses are listed on an Excel sheet with:
Sheet 1, cell B: Full Name
Sheet 1, cell C: Email Address
Sheet 1, cell E: The sports they wish to play on (there are four)
On sheet 2, I want to organize who and how many people want to play on each team. So I have a column for each sport, and under those are two columns (Full name and email address).
What I want to do is to parse through Sheet 1, cell E for each person who signed up, and if they have the instance of one of the four sports listed (Soccer, Dodgeball, Volleyball, or Bowling), add their Full name and email address under the correct column in sheet 2.
This is an image of sheet 2.
Is there a way/formula to be able to do this? Also, if the person signed up for multiple sports, they should be listed under each one. All the sports they want to play will be listed under a single cell (Sheet 1, cell E).
There is a way, with an array formula (entered with Ctrl+Shift+Enter)... In cell A3:
=IFERROR(INDEX(Sheet1!$B$1:$B$500,SMALL(IF(ISERROR(SEARCH(A$1,Sheet1!$E$1:$E$500)),9999,ROW(Sheet1!$A$1:$A$500)),ROW()-2)),"")
Let me explain from the inside out...
ISERROR(SEARCH(A$1,Sheet1!E10)) would give us FALSE if the value in E10 has the name of the sport (in our header cell: A$1), TRUE otherwise
Rather than just giving a single value, we are working on the array of cells Sheet1!$E$1:$E$500 (which could be extended as you needed) - so this gives us an array of TRUE and FALSE values
IF(ISERROR(...),9999,ROW(...)) means that if there was not the sport we will get the value 9999, otherwise we get the row number of the cell in the array - so this gives us an array of a mix of 9999 and row numbers
SMALL(...,ROW()-2) lets us pick out one of those values from the array - in this case the items in size order, and we are using ROW()-2 as our counter (i.e. in Sheet2!A3 - ROW()-2 is 1 and we get the smallest value from the array)... the -2 deals with the header rows... Effectively we are indexing through a sorted list of row numbers in Sheet1 that match our condition
INDEX(Sheet1!$B$1:$B$500,...) is going to give us the value from column B in Sheet1 relating to our position in the list of matching rows - i.e. the Name
Sometimes we have our 9999 (for all the cells that didn't match the condition - these are sorted to the end of the list with SMALL) and so the INDEX will give us an error... the index is outside the range. So we can replace it with a blank.
In cell B3 we would do the same, but with =IFERROR(INDEX(Sheet1!$C$1:$C$500,... so that we get the email... We still need to reference A$1 for the sport name. These two cells can then be copied across and down...
Hope this makes some sense! Good luck! And remember to enter array formulas with Ctrl+Shift+Enter...
Basically my problem is that I have a string in one cell in excel, I then need to see if that string exists in another row (not one cell but the whole row) and if so then print the contents of another cell in the same row but in another column.
I will give a basic example:
Title Answer
Police 15
Ambulance 20
Fire 89
Now I need to scan the title column for, say, "Police" and then populate the cell with the value under Answer (in this case 15).
I cant just say IF(A2="Police";B2;"" as I need the scan the whole of the Title column.
I have tried using IF(COUNTIF(A$2:A$100;"Police"); which scans the contents of A2 to A100 for the string Police, and know how to make it print a constant (just put something after the ;) but cant work out how to make that "constant" a variable that changes depending on the found row. So if the COUNTIF found Police in cell A44 then the answer to my formula would be B44, the same as if it found Police in A62 then my formula should show B62
I hope this makes sense and that someone can help me :)
Note that I am using excel 2010 and need a normal formula as I can not use scripting for this document.
EDIT:
Here is what I have so far, note that the spreadsheet I am using is far more complex than the "simple" example I have in the question...
=IF(ISNUMBER(FIND("RuhrP";F9));LOOKUP(A9;Ruhrpumpen!A$5:A$100;Ruhrpumpen!I$5:I$100);"")
This is showing "RuhrP" in every answer where "RuhrP" is found in F9 and not the answer I want which should be that found in RuhrPumpen!I$5:I$100 where the cell index is the same as that for the A coloum where A9 was found. Again, sorry for the complexity I cant think of any better way to word it.
I note you suggested this formula
=IF(ISNUMBER(FIND("RuhrP";F9));LOOKUP(A9;Ruhrpumpen!A$5:A$100;Ruhrpumpen!I$5:I$100);"")
.....but LOOKUP isn't appropriate here because I assume you want an exact match (LOOKUP won't guarantee that and also data in lookup range has to be sorted), so VLOOKUP or INDEX/MATCH would be better....and you can also use IFERROR to avoid the IF function, i.e
=IFERROR(VLOOKUP(A9;Ruhrpumpen!A$5:Z$100;9;0);"")
Note: VLOOKUP always looks up the lookup value (A9) in the first column of the "table array" and returns a value from the nth column of the "table array" where n is defined by col_index_num, in this case 9
INDEX/MATCH is sometimes more flexible because you can explicitly define the lookup column and the return column (and return column can be to the left of the lookup column which can't be the case in VLOOKUP), so that would look like this:
=IFERROR(INDEX(Ruhrpumpen!I$5:I$100;MATCH(A9;Ruhrpumpen!A$5:A$100;0));"")
INDEX/MATCH also allows you to more easily return multiple values from different columns, e.g. by using $ signs in front of A9 and the lookup range Ruhrpumpen!A$5:A$100, i.e.
=IFERROR(INDEX(Ruhrpumpen!I$5:I$100;MATCH($A9;Ruhrpumpen!$A$5:$A$100;0));"")
this version can be dragged across to get successive values from column I, column J, column K etc.....
Assuming
source data range is A1:B100.
query cell is D1 (here you will input Police or Fire).
result cell is E1
Formula in E1 = VLOOKUP(D1, A1:B100, 2, FALSE)
I figured out such data design:
Main sheet:
Column A: Pump codes (numbers)
Column B: formula showing a corresponding row in sheet 'Ruhrpumpen'
=ROW(Pump_codes)+MATCH(A2;Ruhrpumpen!$I$5:$I$100;0)
Formulae have ";" instead of ",", it should be also German notation. If not, pleace replace.
Column C: formula showing data in 'Ruhrpumpen' column A from a row found by formula in col B
=INDIRECT("Ruhrpumpen!A"&$B2)
Column D: formula showing data in 'Ruhrpumpen' column B from a row found by formula in col B:
=INDIRECT("Ruhrpumpen!B"&$B2)
Sheet 'Ruhrpumpen':
Column A: some data about a certain pump
Column B: some more data
Column I: pump codes. Beginning of the list includes defined name 'Pump_codes' used by the formula in column B of the main sheet.
Spreadsheet example: http://www.bumpclub.ee/~jyri_r/Excel/Data_from_other_sheet_by_code_row.xls
Guys Its very interesting to know that many of us face the problem of replication of lookup value while using the Vlookup/Index with Match or Hlookup.... If we have duplicate value in a cell we all know, Vlookup will pick up against the first item would be matching in loopkup array....So here is solution for you all...
e.g.
in Column A we have field called company....
Column A Column B Column C
Company_Name Value
Monster 25000
Naukri 30000
WNS 80000
American Express 40000
Bank of America 50000
Alcatel Lucent 35000
Google 75000
Microsoft 60000
Monster 35000
Bank of America 15000
Now if you lookup the above dataset, you would see the duplicity is in Company Name at Row No# 10 & 11. So if you put the vlookup, the data will be picking up which comes first..But if you use the below formula, you can make your lookup value Unique and can pick any data easily without having any dispute or facing any problem
Put the formula in C2.........A2&"_"&COUNTIF(A2:$A$2,A2)..........Result will be Monster_1 for first line item and for row no 10 & 11.....Monster_2, Bank of America_2 respectively....Here you go now you have the unique value so now you can pick any data easily now..
Cheers!!!
Anil Dhawan