Match values from two tables in excel - excel

One table has policy numbers and the agent who wrote each policy. An agent's name multiple times.
Another table has just the policy numbers and I want to add the agents' names next to the numbers.
VLOOKUP doesn't work because the firs table shows the agents' names multiple times.
Any ideas how to do this?

If the numbers are unique and only the Agents are duplicates, you can use Index/Match or Vlookup.
With Index / Match:
=IFERROR(INDEX(Policy!$B$2:$B$15,MATCH(A2,Policy!$A$2:$A$15,0)),"")
Policy is the sheet where you have Numbers (Column A, A2:A5)and corresponding Agent (Column B, B2:B15) change the references to correspond the last row but keep $ for fixed references. You can drag it down next to A2 where the numbers that you need to find their Agent are.
With Vlookup:
=IFERROR(VLOOKUP(A2,Policy!$A$2:$B$15,2,FALSE),"")
You can drag it down, next to A2 where the numbers are in the new sheet.
Also change Policy!$A$2:$B$15 to correspond the references of your Data.
2 to return the value from the second column (Agent)
False for exact match.

Related

Want a named list with non-continuous cells

I thought this should be a common thing but my search has not returned anything meaningful. I'd prefer an Excel solution, rather than VBA.
I have a proposal sheet with details like number (col D), date etc and a column saying if the proposal got converted (to business).
On the invoice sheet, I have a list of invoices. The requirement is to always refer the proposal number against which this invoice is being raised. For removing human error, the applicable proposal numbers should be available as a drop down. Hence the drop down should only show the proposal numbers against which the invoice can be issued (proposal got converted to business).
This means that non-continuous cells (say, D3, D4, D6, and D10 - where proposal converted is 'yes') from the proposal sheet should be the values available in drop down of data validation in the invoice sheet. How do I achieve this?
Edit:
Adding an image that is representative of the 2 sheets.
My solution involves creating a list using the INDEX MATCH or INDEX SMALL method to pull multiple results from the data that can be used for the dropdown.
I added a couple of extra columns to count the number of times an invoice has been invoiced and then a further Yes/No to make the index formula easier to follow. You'll see that my example only has 2 values to select from as the others have been fully invoiced.
The scary formula in Q1
=IFERROR(INDEX($A$2:$H$1000,SMALL(IF(($H$2:$H$1000="Yes"),ROW($A$2:$H$1000)-1),ROW(1:1)),1),"")
This is an array formula so you must use SHIFTCTRLENTER instead of just ENTER in the formula bar. {} backets will be added if you do it right.
To break it down, INDEX($A$2:$H$1000 is selecting your proposal data and some more rows below (1000). SMALL(IF(($H$2:$H$1000="Yes") is looking at my extra Yes/No column for "Yes". ROW($A$2:$H$1000)-1) is returning the row number minus 1 to account for the fact that our range starts at A2. ROW(1:1) is saying that we want first match in the list and the ),1) returns the vlue in the first column of the range $A$2:$H$1000.
Because ROW(1:1) returns the first result, you will need to autofill down in order to pull more results. As you do this the formula will copy down as 1:1, 2:2, 3:3...ect. I filled down to row 50 to allow for a decent amount of results.
You could set your validation range to Q1:Q50 but then you would have lots of empty space in your dropdown so, have a look at cell R1.
="Q1:Q" & COUNTA(Q1:Q50)-COUNTBLANK(Q1:Q50)
This formula creates a range based on the results in column Q. You can use that value in the data validation range by entering.
=INDIRECT($R$1)
Thus creating the dynamic range that you require.
You don't have to use the extra columns that I added but the formulas are;
=COUNTIF(M2:M1000,A2) to count the number invoiced
=IF(AND(F2="Yes",G2<E2),"Yes","No") to check if it can still be invoiced.
if you do want to use them then I'd recommend formatting your data as a table so that the formulas are copied down automatically on new rows.
Also I'd advise putting the index list on a different sheet so that rows are not deletes etc.

Combining multiple columns (Excel) into 1 with associated column of dates

Reviewed many threads on similar issues, but none addresses my particular challenge. I have a column (A) of dates (10K+), followed by a column (B) of event hosts, followed by multiple columns (C-X) of co-hosts. From these, I need to create 2 columns - 1 of dates and 1 combined list of hosts/co-hosts (each associated with their specific date). In other words, the co-host listings will be inserted into the host list (as a new row) and the appropriate associated date will be generated in the adjacent date column.
Caveats: (1) there are blank cells (in co-host columns), which need to be ignored; (2) the list will continue to expand each year (+~5K); (3) prefer a formulaic solution, if possible.
Can anyone assist? Many thanks!
For a formula way of doing this I would add the following formula into column Y
=B1
And then the following formula into Column Z:
=X1 & IF(LEN(C1)>0,", "&C1,"")
Then drag that formula across to the right for the 22 or so columns (the number between B and X). The last column should have what you are after, you could then Ctrl-X to a different part of the workbook. I have assumed you would like a column between the names. I hope that helps

If a name in a column is a match, count certain text in the row

I have a column/list of duplicate names.
In the corresponding row/columns of duplicate names, some cells contain "Truant."
Another column contains the unique names off that same list.
I want a formula next to the Unique name (listed once) that shows how many "Truant" cells a name has beside it.
For example:
John Smith might be in Column A five times, and in the 9 cells in the same row "Truant" shows up sporadically. I have a column that contains John's unique name once. In the column next to his name, I want it to show how many Truants were in cells in the same rows as his duplicated name... I wish I could post my attachment!
I suggest in two steps:
1) count each row, say with:
=COUNTIF(B2:J2,"Truant")
(as in K2 and copied down) then:
2) in your table of unique names sum with say:
=SUMIF(A:A,M2,K:K)
However there are various alternatives with other functions or a PivotTable that might prove more convenient in the long-term, specially if you did not mind indicating truancy with 1 rather than Truant.

Complex Lookup Function in Excel using 4 different lookup parameters

I am working on a project within an excel database and am trying to match 4 different properties which all have their own columns (A,B,C,D) to find a corresponding value on a different page (Sheet2!). One sheet 2 the values are once again found in their own columns (B,C,D,E) and if all of the values match I then want the value in column A Sheet2! to be displayed in column E on sheet1!
The problem is is that often times the values on Sheet1! will be able to match up with as many as 12 different unique rows on Sheet2! making this incredibly difficult with only intermediate experience in VBA. There can be duplicates that match all of the criteria. And for when this happens I would like to return the first item that matches, as long as a previous match was not made on that item.
To give you more information we have given products different values that designate where they belong based off their velocity. This has split them up into Section#, ShelvingType, Verticle, and Horizontal Location. And we are looking to match these values to the values of our previously existing locations that we have that have corresponding(matching) numbers or text values.
To go into even more detail, on sheet one we have the products with values on where they should go. One sheet two with have pre-existing locations for which products can go that have values that are represntative of that location. So, we want to take the products NEW location values off page one and match the existing location values on page two. The problem is that for every location there are up to 12products that could go there. So, we want to go in order saying that product1 goes in the first location with matched values while product2 goes in the next location with matched values, and so on and so fourth
Edited to remove previous responses
Based on your further elaboration, if I understand correctly, I agree with the comment left by #Aaron Contreras. You should create helper columns which show a 'unique ID' where all criteria match, as well as an additional helper column which increases as more items of the same criteria code are found. This will become the 'ultra-unique' ID for that item.
At this point I don't think array formulas will be possible, though I will leave in the answer which provides the result of the first matching criteria without further eliminating 'previously used' results. This could likely be further refined, but I doubt it would be more elegant than simply using the helper columns shown in my response below. At least, I can't figure out how to do it elegantly.
To summarize my assumptions:
-Your available space is in sheet1; column A contaions something like the location of that available space, and columns B-E contain criteria for anything which will be stored there.
-Your new list of items to be placed in a location is in sheet2; columnA will be where our formula goes, showing the available location to put that item.
Enter on Sheet1
In column F on sheet1, drag down this formula:
=B1&C1&D1&E1
This will create a unique ID key to be searched in the future.
However, as there will be multiple hits for the same criteria on sheet1 (because multiple locations can hold the same thing), we need to make each row 'more unique' by showing how many times that criteria combination has already occurred. This formula will thus go in column G on sheet1, starting in cell G1 and dragged down:
=F1&countif($F$1:F1,F1)
As you drag it down, this will count the nth time that the specific combination of criteria has appeared on sheet1.
Enter on Sheet2
Create the same columns in sheet2, in columns F & G. The formulas will be exactly the same, they will just refer to sheet2 instead of sheet1.
Then the formula in column A in sheet 2, dragged down from A1, would be:
=index(sheet1!A:A,match(G1,sheet1!G:G,0))
This will find the first time that all criteria match from sheet1, for the nth time that this criteria has been used on sheet 2.
Let me know if there is anything here I've missed.
Unfinished array method
Again, array responses are possible, but for your purposes likely unnecesarry; you should probably have a unique ID for all combinations anyway. However, in case you want to use the array method, you can like so (does not account for multiple locations being used; left for reference only if you want to take this up):
In sheet2, enter the following formula [confirmed with CTRL + SHIFT + ENTER instead of just ENTER, every time the formula is changed] on the row 1, with the different criteria (and copied down):
=index(Sheet1!A1:A100,match(1,(Sheet1!B1:B100=B1)(Sheet1!C1:C100=C1)(Sheet1!D1:D100=D1)*(Sheet1!E1:E100=E1),0))
This uses the inherent boolean logic of "TRUExTRUE = TRUE; TRUExFALSE = FALSE; FALSExFALSE = FALSE", to find the first row where there is a match of all criteria. Note that I have not made this go all the way down all columns, as with Array formulas this is a significant resource hog.
Assuming that your data starts from 2nd row (1st row for lables):
{MATCH(A1&B1&C1&D1,B2:B100&C2:C100&D2:D100&E2:E100,0)}
The above is an array formula, so you don't have to input the curly brackets {.
Simply press Ctrl + Shift + Enter after typing the formula
More info

Compare two columns and export unique values

Ok, I have a master list of customer names on sheet 3, column c. On sheet 1, column c, I type the names of the customers I have contacted. I want sheet 2, column c, to show a list of the names of customers that I haven't contacted yet. And I need it to update each time I type a name into sheet 1 that matches a name on sheet three.
The easiest way is with is to create a table on each sheet, sort it, then use IF, ISERROR and MATCH function to show duplicates. Here is a tutorial.
HTH,
M
Populate Sheet2 C1 and down with the following formula:
=IFERROR(IF(VLOOKUP(Sheet3!C1,Sheet1!C$1:C$10,1,0)=Sheet3!C1,""),Sheet3!C1).
As with user3654439's answer, which is good BTW, this will create a column that includes blanks which can be filtered out if desired. There is no need to make a table nor sort the data to get the formula to work. Also in the part of the formula Sheet1!C$1:C$10 the 10could be changed to match the length of the list of customers that you intend to contact.

Resources