formula to search rows then allocate specific name from another table - excel

I have a spreadsheet that is pulling in call survey data and set up as follows
Main sheet is called 'Data'
In the main sheet, columns F,G,H,I hold agent ID numbers dependant on what agents worked on this specific call through it's journey to end. All agent numbers start with the prefix either of 146,144 or 145.
so for example 1st agent 14400 took the call then transferred to agent 14600 then that one onto agent 14500.
Sheet 2 is called 'Teams'
Column A holds agent ID's
Column B is team name
What i want to be able to put a formula in column A of the sheet 'Data' which will then search through rows until it finds a number begining 146.
Once it has found this number it will then search the sheet 'teams' and allocate the required team manager name from column C.
Hope this all makes sense but please let me know if not.
Thanks

This is the solution (I tested it on your spreadsheet):
=VLOOKUP(SUMPRODUCT(--(F2:I2>=146000),--(F2:I2<=146999),F2:I2),Teams!A:C,3,FALSE)
--(F2:I2>=146000) return an array with 0 or 1, 1 if the value is greater than 146000, --(F2:I2<=146999) same but 1 if value less than 146999
SUMPRODUCT is a logical and between the three array that return the value 146xxx. to know more sumproduct
VLOOKUP search in the first column of the range A:C on the Teams' sheet for the id and return the content of the third column.
If you want to have a custom result if the 146xxx is not present in the row you have to use IFERROR(VLOOKUP(..),"TEXT_TO_SHOW")

Related

How to transfer data between files?

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.

VLOOKUP or INDEX-MATCH for text from bottom to the top with reference to another sheet in the workbook

I am making a log for work and in one of the columns, I need a formula that fills each cell with the latest text information from another sheet in the same workbook. I have attached a picture of the worksheet I am working in and a picture of the referenced worksheet.
The worksheet I need the formula in
The worksheet with the reference cells
In image 1, there are 2 column titles highlighted. Column 'A' and Column 'S'. Column A is the id of one of my animals, and column S is supposed to have a date/initial in there for my macro to work. However, people forget to fill it in and only fill it in the sheet from image 2 in Column 'P'. Because we reuse the same animal more than once the information that goes into column S in the first image always needs to be the newest information from the reference sheet. I know how to do a VLOOKUP with the dates, I have already done those, but because I need the cell to populate with text instead of numerical values, I am having trouble.
I will list some formulas I have tried that are supposed to go from the bottom to the top but don't work and maybe just need to tweak and some that work if I was going from the top to the bottom.
Formulas that don't work going from the bottom to the top but I'd think would:
=LOOKUP(2,1/(FIND(A18,BREEDING!D:D)),P:P)
=INDEX(BREEDING!P:P,MATCH(A21,BREEDING!D:D,0))
=LOOKUP(2,1/(BREEDING!D:D=A21),BREEDING:P:P)
Formulas that do work but go from the top to the bottom:
=(VLOOKUP(A17,BREEDING!D:Q,13,FALSE))
References:
Column A: Animal ID that is present in the 1st image
Column D: Animal ID that is present in the 2nd image
Column S: 'Date Weaned' cell that will contain the formula and information from the 2nd image should populate into
Column P: The actual date weaned that should go into column S of the 1st image
TL;DR
In image 1, cells in column S should have the latest text information from column P of image 2 if the information from Column A of image 1 matches the information from Column D of image 2
Formula that you could use is below
=INDEX(BREEDING!P:P;AGGREGATE(14;6;ROW(BREEDING!D:D)/(BREEDING!D:D=A2);1))
how it works - the index is simple, the aggregate the is main thing - it uses 14 as first parameter which is function LARGE (return k-th largest value) and then the 6 is the most important, because that means "skip errors". This is vital, because when you divide by (BREEDING!D:D=A2) it divides by 0 or 1 based on false/true so creates lot of errors and keeps only the lines with Animal ID equal to Animal ID of the line. Then it uses LARGE function on all lines with that Animal ID and because of the last part ";1))" it returns the highest row number where the Animal ID matches. This way you should be able to get the value from your second sheet for the newest (highest row number) line.
The formula can be quite resource-intensive so you might have to repaste as values - if you are periodically running a macro on the data you can have it also apply the formula and then change to values if it gets too long to calculate every time you want to change something...

Index and Match with mulitple sheets and parameters

At work we have a large collection of sheet that I'm trying to add a couple columns to.
Some of the Index functions were already in the sheets so I am trying to base my new index function off of it because I have never used these types of functions in Excel. The old function is as follows.
=INDEX('Order Detail'!$D:$D,MATCH($A9,'Order Detail'!$B:$B,0))
Order detail is the name of the sheet that is holding the date for the output.
A9 is the part number in the current sheet.
And the part numbers are listed in column B or the order detail sheet.
What I know want to do is match the part numbers for the two sheets and match the dept number. The dept number is located in column L of the order detail sheet and I want that to match 1000-1. Not 1000 minus 1 actual 1000-1.
IF both of those match I want to spit out the data from column O in the order detail sheet and output that in column U starting at U9 and down in the current sheet.
This is what I have so far for this but it does not work.
=INDEX('Job Routing'!$O:$O,MATCH($A9,'Job Routing'!$B:$B,0),MATCH('Job Routing'!$L:$L,"1000-1"),0)
I only want it to output the O column if the Part Number AND Dept Number are the same as the part number in A9 and the dept number the same as 1000-1.
Any ideas?
Thanks

Excel: Copy cell info based on string match from another sheet

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...

Excel: If Cell in Column = text value of X, then display text (in the same row, but different column) on another sheet

This is a confusing request.
I have an excel tab with a lot of data, for now I'll focus on 3 points of that data.
Team
Quarter
Task Name
In one tab I have a long list of this data displaying all the tasks for all the teams and what Quarter they will be on.
I WANT to load another tab, and take that data (from the original tab) and insert it into a non-list format. So I would have Quarters 1,2,3,4 as columns going across the screen, and Team Groups going down. I want each "task" that is labeled as Q1 to know to list in the Q1 section of that Teams "Block"
So something like this: "If Column A=TeamA,AND Quarter=Q1, then insert Task Name ... here."
Basically, if the formula = true, I want to print a list of those items within that team section of the excel document.
I'd like to be able to add/move things around at the data level, and have things automatically shift in the Display tab. I honestly have no idea where to start.
If there is never a possibility that there could be more that 1 task for a given team and quarter, then you can use a formula solution.
Given a data setup like this (in a sheet named 'Sheet1'):
And expected results like this (in a different sheet):
The formula in cell B2 and copied over and down is:
=IFERROR(INDEX(Sheet1!$C$2:$C$7,MATCH(1,INDEX((Sheet1!$A$2:$A$7=$A2)*(Sheet1!$B$2:$B$7=B$1),),0)),"")
I came across this situation. When I have to insert the values into a table from an Excel sheet I need all information in 1 Column instead of 2 multiple rows. In Excel my Data looks like:
ProductID----OrderID
9353510---- 1212259
9650934---- 1381676
9572474---- 1381677
9632365---- 1374217
9353182---- 1212260
9353182---- 1219361
9353182---- 1212815
9353513---- 1130308
9353320---- 1130288
9360957---- 1187479
9353077---- 1104558
9353077---- 1130926
9353124---- 1300853
I wanted single row for each product in shape of
(ProductID,'OrdersIDn1,OrderIDn2,.....')
For quick solution I fix it with a third column ColumnC to number the Sale of Product
=IF(A2<>A1,1,IF(A2=A1,C1+1,1))
and fourth Column D as a placeholder to concatenate with previous row value of same product:
=IF(A2=A1,D1+","&TEXT(B2,"########"),TEXT(B2,"########"))
Then Column E is the final column I required to hide/blank out duplicate row values and keep only the correct one:
=IF(A2<>A3,"("&A2&",'"&D2&"'),","")
Final Output required is only from Column E
ProductID Order Id Sno PlaceHolder Required Column
9353510 1212259 1 1212259 (9353510,'1212259'),
9650934 1381676 1 1381676 (9650934,'1381676'),
9572474 1381677 1 1381677 (9572474,'1381677'),
9632365 1374217 1 1374217 (9632365,'1374217'),
9353182 1212260 1 1212260
9353182 1219361 2 1212260,1219361
9353182 1212815 3 1212260,1219361,1212815 (9353182,'1212260,1219361,1212815'),
9353513 1130308 1 1130308 (9353513,'1130308'),
9353320 1130288 1 1130288 (9353320,'1130288'),
9360957 1187479 1 1187479 (9360957,'1187479'),
9353077 1104558 1 1104558
9353077 1130926 2 1104558,1130926 (9353077,'1104558,1130926')
You will notice that final values are only with the Maximum Number of ProductSno which I need to avoid duplication ..
In Your case Product could be Team and Order could be Quarter and Output could be
(Team,Q1,Q2,....),
Based on my understanding of your summary above, you want to put non-numerical data into a grid of teams and quarters.
The offset worksheet function will work well for this in conjunction with the match or vlookup functions. I have often done this task by doing the following steps.
In my data table, I have to concatenate the Team and quarter columns so I have a unique lookup value at the leftmost column of your table (Note: you can eventually hide this for ease of reading).
Note: You will want to name the input range for best formula management. Ideally use an Excel Table (2007 or greater) or create a dynamically named range with the offset and CountA functions working together (http://tinyurl.com/yfhfsal)
First, VLOOKUP arguments are VLOOKUP(Lookup_Value,Table_Array,Col_Index_num,[Range Lookup]) See http://tinyurl.com/22t64x7
In the first cell of your output area you would have a VLOOKUP formula that would look like this
=Vlookup(TeamName&Quarter,Input_List,Column#_Where_Tasks_Are,False)
The Lookup value should be referencing cells where you have the team names and quarter names listed down the sides and across the top. The input list is from the sheet you have the data stored. The number three represents the column number the tasks are listed in your source data, and the False tells the function it will only use an exact match in your putput.

Resources