I am trying to create a formula that checks Column A for unique values, then takes that value and checks column B for unique values and orders them sequentially in Column C. Column C is the where the formula goes. It's not in the actual data set.
This is what I want my data set to look like.
For example, I want to find unique Entry Number "123-A. I then want to look within that entry number and find the unique codes in Column B and order them sequentially. The first two are the same, so they both are sequence 1. Then the third row as a new code, "Y09", so it will get sequence 2. Once the next unique entry number is identified, I want to reset the sequential count. Thanks!
So, the first thing we want to do is check if a number has already been allocated. Since there are 2 columns to check, we need to use INDEX MATCH with an Array Condition instead of just a VLOOKUP:
INDEX($C$1:$C1, MATCH(1, ($A$1:$A1=$A2)*($B$1:$B1=$B2), 0))
These formula are intended for cell C2 - notice how we left the second cell in each Range reference without the $ to lock it in place. This means it will always stop at the row above the formula
If this works, we're done. If it doesn't we get an error - so, we can use IFERROR:
=IFERROR(INDEX($C$1:$C1, MATCH(1, ($A$1:$A1=$A2)*($B$1:$B1=$B2), 0)), ???)
On to replacing those question marks!
Since we don't have a match, we need to find the largest match for the Entry Number, and add 1 for it. If you have Office365 or Office2019, we can just use the MAXIFS function. Otherwise, we will have to use SUMPRODUCT and MAX to get the same result: (If the Entry Number does not exist, this will return 0)
MAXIFS($C$1:$C1, $A$1:$A1, $A2)
SUMPRODUCT(MAX($C$1:$C1 * ($A$1:$A1=$A2)))
Then, Add 1:
=IFERROR(INDEX($C$1:$C1, MATCH(1, ($A$1:$A1=$A2)*($B$1:$B1=$B2), 0)), MAXIFS($C$1:$C1, $A$1:$A1, $A2) + 1)
=IFERROR(INDEX($C$1:$C1, MATCH(1, ($A$1:$A1=$A2)*($B$1:$B1=$B2), 0)), SUMPRODUCT(MAX($C$1:$C1 * ($A$1:$A1=$A2))) + 1)
It appears that your data is already organized/sorted by the column A and B values. If this is the case, we can construct a formula implementing the following rules:
if the adjacent A and B values match the values above them, copy down the C value from above
if the adjacent A value matches the value above it, but the B value does not, then increment the C value from above.
If the A value does not the value above it, then set the C value to 1
In C2 enter 1. In C3 enter:
=IF(AND(A3=A2,B3=B2),C2,IF(A3=A2,C2+1,1))
and copy downward:
if your data is not organized in the same way your picture indicates, then ignore this solution.
Related
I'm trying to create auto numbering for Agents that are currently present and has numbers including zeroes 0 in 3rd or 4th column(zero meaning they don't get any stats but they are present)
Agents who has TEXT Value in the 3rd or 4th column are those who are not present (Ex: A = Absent, SL = Sick Leave, VL = Vacation Leave). Meaning, they should not be counted, therefore their value on 1st column should be blank, and therefore this should not stop the auto numbering for the rest of the agents below and should continue the count in sequence.
Can anyone help create formula that would fill the numbers on the 1st column automatically for those agents that are present and has value including 0 on column 3 or 4 (stats 1 or stats 2)?
To give more idea, I'm trying to show the current total number of agents who are currently present in this situation and will count their stats, and exclude all other agents who are not present and should not be counted.
Thank you!
Sequence Two Numeric Columns
Single Cell
In cell A3, a basic not spilling formula would be...
=IF(AND(ISNUMBER(C3),ISNUMBER(D3)),MAX(A$2:A2)+1,"")
... with the condition of a string in cell A2.
Without any conditions, you could try an improved version, similar to one of David Leal's suggestions:
=IF(AND(ISNUMBER(C3),ISNUMBER(D3)),
SUM(ISNUMBER(C$3:C3)*ISNUMBER(D$3:D3)),"")
Spill
In cell A3 you could use the following:
=LET(Data1,C3:C13,Data2,D3:D13,
Data,ISNUMBER(Data1)*ISNUMBER(Data2),
IFERROR(SCAN(0,Data,LAMBDA(a,b,a+b))/Data,""))
Line1: the inputs ('constants'), the same-sized single-column ranges
Line2: the zeros and ones, where the ones present the data of interest
Line3: the formula to replace the ones with the sequence and the zeros (errors due to division by zero) with an empty string
Converted to a LAMBDA, it could look like the following:
=LAMBDA(Data1,Data2,LET(
Data,ISNUMBER(Data1)*ISNUMBER(Data2),
IFERROR(SCAN(0,Data,LAMBDA(a,b,a+b))/Data,"")))(C3:C13,D3:D13)
Since it's such a long formula, you could create your own Lambda function by using this part...
=LAMBDA(Data1,Data2,LET(
Data,ISNUMBER(Data1)*ISNUMBER(Data2),
IFERROR(SCAN(0,Data,LAMBDA(a,b,a+b))/Data,"")))
... to define a name, e.g. SeqNumeric, when in the same cell, you could use
it simply with...
=SeqNumeric(C3:C13,D3:D13)
... instead.
Now you can use the function like any other Excel function anywhere in the workbook.
The Path
F3 =ISNUMBER(C3:C13)*ISNUMBER(D3:D13) - multiply: zeros-no, ones-yes
G3 =SCAN(0,F3#,LAMBDA(a,b,a+b)) - use the 'LAMBDA' helper function 'SCAN'
H3 =G3#/F3# - divide the 'scan' result by the zeros and ones
I3 =IFERROR(H3#,"") - convert the '#DIV/0!' errors to empty strings
The translation of the SCAN part could be something like the following:
Set the initial result a to 0.
Create a new array of the size of the initial array in F3#.
Loop through each element of the initial array, write its value to b, and replace a with the sum of a+b.
Write (the accumulated) a to the current element of the new array and repeat for the remaining elements of either array.
Return the new array.
Combine all of it in a LET.
J3 =LET(Data1,C3:C13,Data2,D3:D13,
Data,ISNUMBER(Data1)*ISNUMBER(Data2),
IFERROR(SCAN(0,Data,LAMBDA(a,b,a+b))/Data,""))
Convert to LAMBDA.
K3 =LAMBDA(Data1,Data2,LET(
Data,ISNUMBER(Data1)*ISNUMBER(Data2),
IFERROR(SCAN(0,Data,LAMBDA(a,b,a+b))/Data,"")))(C3:C13,D3:D13)
Copy the first part of the LAMBDA (note how it results in a #CALC! error since no parameters are supplied)...
L3 =LAMBDA(Data1,Data2,LET(
Data,ISNUMBER(Data1)*ISNUMBER(Data2),
IFERROR(SCAN(0,Data,LAMBDA(a,b,a+b))/Data,"")))
... and select Formulas -> Name Manager -> New to create your own function and finally use it with the following:
A3 =SeqNumeric(C3:C13,D3:D13)
You can try the following in cell A1:
=LET(B, B2:B12, C, C2:C12, f, 1*ISNUMBER(B*C),seq, SEQUENCE(ROWS(B)),
MAP(seq, LAMBDA(s, IF(INDEX(f,s)=0, "",SUM(FILTER(f, (seq<=s),0))))))
Here is the output:
A non-array version, expanding down the formula would be:
=IF(ISNUMBER(B2*C2), SUM(1*ISNUMBER(B$2:B2*C$2:C2)),"")
For the array version, it counts only if both columns Stat1 and Stat2 are numeric. The name f, has a value of 1 if the condition is TRUE, otherwise is 0. The MAP does the count if the index position of the f array is not zero, otherwise returns an empty string.
I think I got it.
This is the formula that I made
=IF(COUNTIFS(D2:BE2,"*",$D$1:$BE$1,TODAY())>0,"",MAX(A1:A$4)+1)
Countif criteria 1 = if the cell contains a letter and is counted > 0 then it will return blank, otherwise it will start the count using max function. The countif criteria 2 will will return the correct value according to the date today since the excel sheet has several data daily.
A
B
C
D
4
1
6
5649
3
8
10
9853
5
2
7
1354
I have two worksheets, for example column A in sheet 1 and columns B-D in sheet 2.
What I want to do is to take one value in Column A, and scan both columns B and C and it is between those two values, then display the corresponding value from column D in a new worksheet.
There could be multiple matches for each of the cell in column A and if there is no match, to skip it and not have anything displayed. Is there a way to code this and somehow create a loop to do all of column A? I tried using this formula, but I think it only matches for each row and not how I want it to.
=IF(AND([PQ.xlsx]Sheet1!$A2>=[PQ.xlsx]Sheet2!$B2,[PQ.xlsx]Sheet1!$A2<[PQ.xlsx]Sheet2!$C2),[PQ.xlsx]Sheet2!$D$2,"")
How do I do this?
Thank you.
I'm not positive if I understood exactly what you intended. In this sheet, I have taken each value in A:A and checked to see if it was between any pair of values in B:C, and then returned each value from D:D where that is true. I did keep this all on a single tab for ease of demonstration, but you can easily change the references to match your own layout. I tested in Excel and then transferred to this Google Sheet, but the functions should work the same.
https://docs.google.com/spreadsheets/d/1-RR1UZC8-AVnRoj1h8JLbnXewmzyDQKuKU49Ef-1F1Y/edit#gid=0
=IFERROR(TRANSPOSE(FILTER($D$2:$D$15, ($A2>=$B$2:$B$15)*($A2<=$C$2:$C$15))), "")
So what I have done is FILTEREDed column D on the two conditions that Ax is >= B:B and <= C:C, then TRANSPOSED the result so that it lays out horizontally instead of vertically, and finally wrapped it in an error trap to avoid #CALC where there are no results returned.
I added some random data to test with. Let me know if this is what you were looking at, or if I misunderstood your intent.
SUPPORT FOR EXCEL VERSIONS WITHOUT DYNAMIC ARRAY FUNCTIONS
You can duplicate this effect with array functions in pre-dynamic array versions of Excel. This is an array function, so it has be finished with SHFT+ENTER. Put it in F2, SHFT+ENTER, and then drag it to fill F2:O15:
=IFERROR(INDEX($D$2:$D$15, SMALL(IF(($A2>=$B$2:$B$15)*($A2<=$C$2:$C$15), ROW($A$2:$A$15)-MIN(ROW($A$2:$A$15))+1), COLUMNS($F$2:F2))),"")
reformatted for easier explanation:
=IFERROR(
INDEX(
$D$2:$D$15,
SMALL(
IF(
($A2>=$B$2:$B$15)*($A2<=$C$2:$C$15),
ROW($A$2:$A$15) - MIN(ROW($A$2:$A$15))+1
),
COLUMNS($F$2:F2)
)
),
"")
From the inside out: ROW($A$2:$A$15) creates an array from 2 to 15, and MIN(ROW($A$2:$A$15))+1 scales it so that no matter which row the range starts in it will return the numbers starting from 1, so ROW($A$2:$A$15) - MIN(ROW($A$2:$A$15))+1 returns an array from 1 to 14.
We use this as the second argument in the IF clause, what to return if TRUE. For the first argument, the logical conditions, we take the same two conditions from the original formula: ($A2>=$B$2:$B$15)*($A2<=$C$2:$C$15). As before, this returns an array of true/false values. So the output of the entire IF clause is an array that consists of the row numbers where the conditions are true or FALSE where the conditions aren't met.
Take that array and pass it to SMALL. SMALL takes an array and returns the kth smallest value from the array. You'll use COLUMNS($F$2:F2) to determine k. COLUMNS returns the number of columns in the range, and since the first cell in the range reference is fixed and the second cell is dynamic, the range will expand when you drag the formula. What this will do is give you the 1st, 2nd, ... kth row numbers that contain matches, since FALSE values aren't returned by SMALL (as a matter of fact they generate an error, which is why the whole formula is wrapped in IFERROR).
Finally, we pass the range with the numbers we want to return (D2:D15 in this case) to INDEX along with the row number we got from SMALL, and INDEX will return the value from that row.
So FILTER is a lot simpler to look at, but you can get it done in an older version. This will also work in Google Sheets, and I added a second tab there with this formula, but array formulas work a little different there. Instead of using SHFT+ENTER to indicate an array formula, Sheets just wraps the formula in ARRAY_FORMULA(). Other than that, the two formulas are the same.
Since FALSE values aren't considered, it will skip those.
Hi I have the following two tables
I am trying to get the col
I am trying to automate Column E so that every time the data changes in cell D2 it would automatically get changed based on the shift patter that the Agent is assigned on that day.
I cannot used vlookup because it will obviously just take the first text found with for example 9am-5pm - all cells would be populated with Agent 3.
=INDEX($A$2:$A$10,AGGREGATE(15,3,($B$2:$B$10=D3)/($B$2:$B$10=D3)*ROW($B$2:$B$10)-1,COUNTIF(D$3:D3,D3)))
As an alternate approach to ZygD's answer.
It uses AGGREGATE. It checks for the values in the B column range to equal the value in column D and divides the result by itself, which will result in 1 if True and multiplies that by the row number. The result gives the row numbers of all TRUEs and checks for the Nth smallest value based on how many of the same agent are already found in your result list above and finally shows the value of that row in your range of values in column A.
Seems like this array formula in E3 in part does what you want (it is entered not using usual Enter key, but instead, Ctrl + Shift + Enter).
=INDEX($A$2:$A$10,SMALL(IF(D3=$B$2:$B$10,ROW($B$2:$B$10)-ROW($B$2)+1),COUNTIF($D$3:D3,D3)))
Use XLOOKUP() instead. Column position does not matter with this function.
I am running a small study that basically needs to match suitable people into pairs and assign them a pair number, so each can be assigned into group A or B.
They basically need to be from the same Medical Clinic, same gender, and either below 80, or 80+ years of age.
I'm not sure if this is even possible with excel, but basically I have a sheet with a form that you enter the new participants information. I need a formula that basically checks these 3 criteria against previous entries to find someone who matches on all 3, then assign the same pair number. If it can't find a suitable match, it needs to assign a new pair number.
In the above sample data set, I want I3 to realise that C3, D3 and E3 all match C2, D2 and E2, then put a 1 in I3.
Then for I4, it would assign a 2 as it doesn't match any entries above it. Same for I5. Then I6 would realise the match in I4 and put a 2.
Not sure if this makes sense. Also there can't be more than 2 of each pair #, but I can deal with that after I am able to get the numbers generating.
If you can change column D to Age group, (71-80, 81-90 etc.) the following formula would do what you want as a first step (more than 2 people grouped together). Paste the following formula in I3 and hit cntrl+shift+enter as it is a array formula. Copy it down to other cells below.
=IFERROR(INDEX(F$1:F2,MATCH(C3&D3&E3,C$1:C2&D$1:D2&E$1:E2,0)),MAX(F$2:F2)+1)
This matches a combination of strings in columns C, D and E in the current row to array of string combination in previous rows and assigns the same Pair number, if there is no match it gets the next new number.
Try this modified formula (array formula) to not put more than two entries in a group. I have created another column G which is G2 = C2&D2&E2
=IF(COUNTIF(G$1:G2,G3)<2,IFERROR(INDEX(F$1:F2,MATCH(C3&D3&E3,C$1:C2&D$1:D2&E$1:E2,0)),MAX(F$2:F2)+1),MAX(F$2:F2)+1)
This response expands on your original requirements by returning the actual PT ID numbers of the matched pairs as well as a unique 'paired group' identifier.
The original criteria age brackets (e.g. 70-80, 81+) are used and no matched pair is used more than once.
If you already have a match from further up the data then you will want to return the paired PT ID. A simple INDEX/MATCH function pair can do that. If a match has not already been made then the IFERROR function can pass processing over to a nested INDEX function that uses the AGGREGATE¹ function rather then MATCH to return the appropriate row number.
AGGREGATE is used with its SMALL sub-function. This allows the COUNTIFS function to increment to the second, third, etc. pairing by examining the matches³ made previously.
With expanded sample data the formula in I2:K2 are,
'formula for I2
=IFERROR(IFERROR(INDEX(B$1:B1, MATCH(B2, I$1:I1, 0)),
INDEX(B:B, AGGREGATE(15, 6, ROW(B$1:INDEX(B:B, MATCH(1E+99, B:B)))/
((B:B<>B2)*(C:C=C2)*(E:E=E2)*IF(D2>80, D:D>80, (D:D>=70)*(D:D<=80))),
COUNTIFS(C$1:C1, C2, E$1:E1, E2, D$1:D1, IF(D2>80, ">80", ">=70"), D$1:D1, IF(D2>80, ">80", "<=80"))+1))),
"NO MATCH")
'formula for J2
=IFERROR(INDEX(J$1:J1, MATCH(I2, B$1:B1, 0)), MAX(J$1:J1)+1)
'formula for K2 (volatile and random - see footnote ⁴)
=IFERROR(IF(INDEX(K$1:K1, MATCH(J2, J$1:J1, 0))="A", "B", "A"), IF(ISNUMBER(I2), CHAR(RANDBETWEEN(65, 66)), ""))
Fill down as necessary.
¹ The AGGREGATE function was introduced with Excel 2010. It is not available in earlier versions.
² While AGGREGATE-based formulas are entered as conventional formulas (i.e. without CSE), AGGREGATE does apply cyclic array-style processing. Try and reduce your full-column references to ranges more closely representing the extents of your actual data. Array processing chews up calculation cycles logarithmically so it is good practise to narrow the referenced ranges to a minimum. See Guidelines and examples of array formulas for more information.
³ Your original narrative stated '... either between 70 and 80 or above 80 years of age.' while your subsequent comment stated 'Under 80 or 80+'. These are not the same thing. I've used the former original description since you never edited the question for clarification.
⁴ The formula destined for K2 is volatile and uses the RANDBETWEEN function. Once you are happy with the results, use Copy, Paste Special, Values to revert the formula to its underlying values. Leaving the formula intact with RANDBETWEEN means the values could change with any change throughout the workbook. Only the initial A/B value for each matched pair is random; the match in the pair will always be the A or B counterpart.
First, you can create a new column (J) that concatenates the 3 values you are comparing, you can do this with a formula like this:
=C2&IF(D2>80,"YES","NO")&D3
The you can fill I2 with a formula that checks is the concatenated value repeats in the data set with a fomula like this:
=COUNTIFS($J$2:$J$6,J2)>1
I am going crazy over this. It seems so simple yet I can't figure this out. I have two worksheets. First worksheet is my data. Second is like an answer key. Upon checking checking, A1:B1 in Sheet 1 is a match with the conditions in Row 52 in SHEET 2, therefore, the value in Column C is "MGC". What is the formula that will perform this function? It's really hard to explain without the data so I pasted a link of the sample spreadsheet. Thank you so much in advance.
sample spreadsheet here. https://docs.google.com/spreadsheets/d/1_AjuNfCdGfEM-XkqPa6W4hSIxQg4NM2Vg4c2C1pQ_vQ/edit?usp=sharing
screenshot here. (wont let me post i have no reputation)
In Sheet2, insert a column in front of Column A and put the formula in A2 =C2&D2.
Then in Sheet1, Cell C2 the formula =vlookup(A2&B2,Sheet2!A:B,2,0).
the first make a concatenated key to lookup, then the second looks up that key.
How about a index(match())? If I've understood correctly you need to match across both the A and B column in sheet one, checking for the relevant values in B and C on sheet 2 to retrun worksheet 2 column a to worksheet 1 column c.
third version try:
=INDEX(Sheet2!$C$1:$C$360,MATCH(Sheet1!A1&Sheet1!B1,Sheet2!$B$1:$B$360&Sheet2!$C$1:$C$360,0))
Basically what this does is use concatenation, the & operator, to specify you are looking for "Criteria A" & "Criteria B" in sheet 1, which makes the string "Criteria A Criteria B", which is supplied in the first part of the match function.
In the second it then says match this against all of my variables in sheet 2 in the same way with concantenation.
The final part of match function (0) specifies you want an 'exact' match
It then supplied this as a reference to the index function, which then finds the row intersecting with the value you want, and returns that.
As noted here https://support.microsoft.com/en-us/kb/59482 this is an array formula, so it behaves differently, and must be input differently. https://support.office.com/en-za/article/Guidelines-and-examples-of-array-formulas-7d94a64e-3ff3-4686-9372-ecfd5caa57c7
There are (at least) 2 ways you could do this without VBA.
USING A SORTED LIST
The first relies on the assumption that your data can be re-sorted, so that everything "Unreported" is in the top, and everything "reported" is together below that (or vice versa). Assuming that this is the case (and it appears to already be sorted like this),we will use the function OFFSET to create a new range which shows only the values that align with either being "Unreported" or "Reported".
Offset takes a given reference to a point on a sheet, and then moves down/up & left/right to see what reference you want to return. Then, it returns a range of cells of a given height, and a given width. Here, we will want to start on Sheet2 at the top left, moving down until we find the term "Unreported" or "Reported". Once that term is found, we will want to move one column to the right (to pull column B from sheet 2), and then have a 'height' of as many rows as there are "unreported" or "reported" cells. This will look as follows in A1 on sheet 1, copied down:
=OFFSET(Sheet2!$A$1,MATCH(A1,Sheet2!A:A,0)-1,1,COUNTIF(Sheet2!A:A,A1),1)
This says: First, start at cell A1 on sheet2. Then find the term in A1 (either "unreported" or "reported", on sheet2!A:A (we subtract 1 because OFFSET starts at A1 - so if your data starts at A1 we need to actually stay at "0". If you have headers on sheet2, you will not need this -1). Then, move 1 column to the right. Go down the rows for as many times as Sheet2 column A has the term found in Sheet1 A1. Stay 1 column wide. Together, this will leave you with a single range on sheet2, showing column B for the entire length that column A matches your term in sheet1 A1.
Now we need to take that OFFSET, and use it to find out when the term in Sheet1 B1 is matched in Sheet2 column B. This will work as follows:
=MATCH(B1,[FORMULA ABOVE],0)
This shows the number of rows down, starting at the special OFFSET array created above, that the term from B1 is matched in column B from sheet2. To use this information to pull the result from column C on sheet 2, we can use the INDEX function, like so:
=INDEX([FORMULA ABOVE],MATCH(B1,[FORMULA ABOVE],0))
Because this would be fairly convoluted to have in a single cell, we can simplify this by using VLOOKUP, which will only require the OFFSET function to be entered a single time. This will work as follows:
=VLOOKUP(B1,[FORMULA ABOVE],2,0)
This takes the OFFSET formula above, finds the matching term in B1, and moves to the 2nd column to get the value from column C in sheet2. Because we are going to use VLOOKUP, the offset formula above will need to be adjusted to provide 2 columns of data instead of 1. Together, this will look as follows:
FINAL FORMULA FOR SHEET1, C1 & COPIED DOWN
=VLOOKUP(B1,OFFSET(Sheet2!$A$1,MATCH(A1,Sheet2!A:A,0)-1,1,COUNTIF(Sheet2!A:A,A1),2),2,0)
OPTION USING ARRAY FORMULAS
The above method will only work if your data is sorted so that the REPORTED and UNREPORTED rows are grouped together. If they cannot be sorted, you can use an ARRAY FORMULA, which essentially takes a formula which would normal apply to a single cell, and runs it over an entire range of cells. It returns an array of results, which must be reduced down to a single value. A basic array formula looks like this [assume for this example that A1 = 1, A2 = 2...A5 = 5]:
=IF(A1:A5>3,A1:A5,"")
Confirm this (and all array functions) by pressing CTRL + SHIFT + ENTER, instead of just ENTER. This looks at each cell from A1:A5, and if the value is bigger than 3, it gives the number from that cell - otherwise, it returns "". In this case, the result would be the array {"";"";"";4;5}. To get the single total of 9, wrap that in a SUM function:
=SUM(IF(A1:A5>3,A1:A5,""))
In your case, we will want to use an array formula to see what row in Sheet2 matches A1 from Sheet1, and B1 from Sheet1. This will look like this:
=IF(Sheet2!$A$1:A$100=A1,IF(Sheet2!$B$1:$B$100,ROW($B$1:$B$100),""),"")
This checks which rows in column A from sheet 2 match A1. For those that do, it then checks which rows in column B from sheet 2 match B1. For those, it pulls the row number from that match. Everything else returns "". Assuming no duplicates, there should only 1 row number which gets returned. To pull that number from the array of results, wrap the whole thing in a MATCH function. Now that you have the row number, you can use an INDEX function to pull the result in Column C with that row, like this:
FINAL ARRAY FORMULA METHOD
=INDEX($C$1:$C$100,MAX(IF(Sheet2!$A$1:A$100=A1,IF(Sheet2!$B$1:$B$100,ROW(Sheet2!$B$1:$B$100),""),"")))
Remember to confirm with CTRL + SHIFT + ENTER instead of just ENTER, when you type this formula. Note that I didn't refer to all of Sheet2!A:A, because array formulas run very slowly over large ranges.
The following formula should work without making any changes to the datasheets.
=INDEX(Sheet2!$A$1:$A$360,MATCH(Sheet1!A1,IF(Sheet2!$C$1:$C$360=Sheet1!B1,Sheet2!$B$1:$B$360),0))
Remember to save this formula as an array with CTRL+SHIFT+ENTER
Documentation on how to use INDEX and MATCH against multiple criteria can be found on Microsoft Support.
It's not clear what you want to do with the multiples that do not have corresponding matches. txed is listed as Unreported twice in Sheet1; kntyctap is listed as Unreported three times. There are only one corresponding match on Sheet2 for each of these.
Non-array Standard Formulas for multiple criteria matches
For Excel 2010 and above use this standard formula in Sheet1!C1:
=IFERROR(INDEX(Sheet2!$A$1:$A$999,AGGREGATE(15,6,ROW(1:999)/((Sheet2!$B$1:$B$999=A2)*(Sheet2!$C$1:$C$999=B1)), COUNTIFS(A$1:A1, A1, B$1:B1, B1))), "")
For version of Excel prior to 2010 use this standard formula in Sheet1!C1:
=IFERROR(INDEX(Sheet2!$A$1:$A$999, SMALL(INDEX(ROW($1:$999)+((Sheet2!$B$1:$B$999<>A1)+(Sheet2!$C$1:$C$999<>B1))*1E+99, , ), COUNTIFS(A$1:A1, A1, B$1:B1, B1))), "")
I've handled error with the IFERROR function in that latter formula. Excel 2003 and previous may have to use an IF(ISERROR(..., ...)) combination.