How do I write a formula to that shows a student's score every time I type the name in an adjacent box or type the subject name? - excel-formula

How do I create a formula to do what's happening by the right please?
I tried Search function, Match function too.

use:
=VLOOKUP(G4&H3; INDEX(SPLIT(FLATTEN(A3:A10&B2:E2&"×"&B3:E10); "×")); 2; )

Excel provides built-in two-dimensional lookup functionality with the INDEX() function. In this case, what you are trying to find is simply =INDEX(B3:E10, row, col ). So all we need is to identify the row number and column number:
The row would be MATCH(G4, A3:A10, 0)
The column would be MATCH(H3, B2:E2, 0)
Thus in cell H4:
=INDEX(B3:E10, MATCH(G4,A3:A10,0), MATCH(H3,B2:E2,0) )

Related

Automation in Excel for shift patterns

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.

How to print a value in table after checking 2 conditions

I have a table with time on the left and number of houses on top. i want to print a value for a specific house in a specific time. i am using vlookup to match the house and the value but unable to match it with time. as seen in the screenshot the value should only b printed fron 12:15 to 12:45. formula i am using is =IFERROR(VLOOKUP(I$10,$B$3:$C$3,2,FALSE),""). Can anyone help to point me in the right direction.
workbook is attached for sample.
sample workbook
Try this in I11 then fill right and down.
=IF(AND($H11>=$B$6, $H11<=$C$6, I$10=$B$3), $C$3, TEXT(,))
Can you try using INDEX of your table, once you know which row and column you want?
You can then get the row and column number from within your range by using MATCH, for example:
column number: =MATCH(10,[housesRange],0)
and
row number: =MATCH([time],[timeRange],0)
This can be combined with index:
=INDEX([fullTable],[rowNumber],[columnNumber])
Assuming you're looking for a 2 dimensional search of the table, you should use vlookup and match:
Let's for the answer's sake define the table range as
A1:J10
the column number (house number) cell is:
I1
and the start time cell is:
I2
vlookup, does a search on a column and returns a result from the found row in a defined column
to find the column to return, we can use match, match would return the column number of a value, so in this case:
=MATCH(I1,A1:A10,0)
The last parameter, 0, refers to an exact match.
with a vlookup, we have the 2d search:
=VLOOKUP(I2,MATCH(I1,A1:A10,0), 1)
Since the time is set as range, I defined the last parameter of vlookup as 1, so it will found the closest time to the search parameter
Hope that helps

How to combine: INDEX + MATCH + ?VLOOKUP?

I'm having an issue with INDEX + MATCH combination:
=INDEX(ALL!$C$1:$I$1,MATCH(TRUE,ALL!C2:I2<>0,0))
At the moment the aforementioned formula does this job to an extent, where if it finds <>0 value in a row it will return header from this specific column. The issue is that the ROW (as above C2:I2) needs to be specified.
I need to vlookup values in the column "A" in sheet "ALL" and based on that, look at corresponding rows between C:I and if the value in that specific row is <>0 then return heading value.
So, in green I would need a formula to pick up numbers from "Data Source" headings, based on value 1 or any value <>0. I'm guessing it all leads somehow to some sort of "vlookup" hybrid.
Any ideas how to combine vlookup in it?
Thanks
If there can only be one '1' per row, I was thinking of this
=SUMIF(INDEX(B:E,MATCH(G2,A:A,0),0),">0",$B$1:$E$1)
Otherwise if there can be more than one '1'
=INDEX($B$1:$E$1,MATCH(TRUE,INDEX(B:E,MATCH(G2,A:A,0),0)>0,0))
to match the first value greater than zero, in this case entered as an array formula.
A simple =SUMIF() formula will do, no other convoluted INDEX() and MATCH() nested formulas required.
Let's presume we have a data-table that starts at B2 and end at
F6, like this:
So now, to comprehend the solution, here's the syntax of SUMIF() formula (Function):
=SUMIF( range, criteria, [sum_range] )
So, what we want to do is:
go over the range of C3:F3 (and each other respective row)
the criteria to when to sum, is when this range contains 1
and we want to sum_range (sum up) fixed array of numbers, so $C$2:$F$2
So the result is (for row 3):
=SUMIF(C3:F3,1,$C$2:$F$2)
and we drag the formula down, producing expected result:
PS: I think this illustrates the point very well, as to why it's important to declare not only what your formula is doing but also, what you're trying to as in whole as there often is a better (easier) way to implement something, that you might not have thought of.
In other words, follow the Minimal, Complete and Verifiable Example

Excel get relative cell value out of a search function result?

Is there a way to check if a text exists and is a unique entry within a column and then get a cells value which is relative to the position of the found cell?
Here is the approach I tried and a more detailed explanation:
I am using this formula to check if a text exists and is a unique entry within the column D.
=COUNTIF(D:D;X1)=1
If that is the case this function returns TRUE.
Is there a way to get the cell's position, which is found by Excel to make the check for the function mentioned above? Moreover I am interested to know if then one can get a relative cell value from the position returned by Excel e.g: 2 columns on the left of the found position.
Do I need a different, maybe nested function or is this only possible with VBA?
What can I do?
=MATCH(D1, X:X, 0) will find the row number of the first D1 in column X, or #N/A if there are none.
=INDEX(V:V, 42) will show the value of cell V42.
Combining this:
=IF(COUNTIF(X:X, D1)=1, INDEX(V:V, MATCH(D1, X:X, 0)), NA())
This should do what you need - if there's a unique match in column X, it shows the corresponding value from column V.
You can take this further by naming the columns, for example:
=IF(COUNTIF(client_email, D1)=1, INDEX(client_name, MATCH(D1, client_email, 0), NA())
This has the upside that you can see you're looking for the client's name if they and only they have a particular email address. And the downside that it's less obvious where on the sheet that data is stored. Swings and roundabouts!

VLOOKUP in last column of Table_array

I understand that VLOOKUP searches the first column of a table in order to find a value, then it grabs the value from the same row and a different user-specified column. The following code returns data from the 2nd column, column B.
VLOOKUP(5,$A$2:B100,2)
Is there a way to set the return column to the last column of the input table? Something like the following, which would return data from columns B, P, and AC, respectively.
VLOOKUP(5,$A$2:B100,end)
VLOOKUP(5,$A$2:P100,end)
VLOOKUP(5,$A$2:AC100,end)
Alternatively, is there a way to grab the current column number and use that as an index?
VLOOKUP(5,$A$2:B100,current_column_number)
I'd like to write one VLOOKUP formula and then be able to drag it right across the spreadsheet, so that B100 becomes C100, D100, E100, etc. and the column lookup changes accordingly.
Update
I can do the alternate approach using the COLUMN function, but it requires programming a fixed offset and doesn't seem as robust. I'd still like to know if there is an "end" option.
=VLOOKUP(5,$A$2:B100,COLUMNS($A$2:B100))
Unfortunately you cannot simply drag it, you'll need to replace as there are two equivalent ranges written in the nested function.
The COLUMNS effectively counts the columns in the range giving the exact result needed for the VLOOKUP's end variant.
EDIT to show OP what a simple drag function would be like:
Function VLOOKUP2(Expected As Variant, Target As Range)
x = Target.Columns.Count
VLOOKUP2 = Application.WorksheetFunction.VLookup(Expected, Target, x)
End Function
You can use the Excel COLUMN() function to convert the column reference to a numerical index into the VLOOKUP table. Try this:
VLOOKUP(5, $A$2:B100, COLUMN(B2))
VLOOKUP(5, $A$2:P100, COLUMN(P2)
VLOOKUP(5, $A$2:AC100, COLUMN(AC2))
In pratice, you can just enter the first formula I gave above and then copy to the right. Each copy will automatically shift the column number to the end.
You could use the count function while holding ($) one side of the count range, thus giving you an integer that Vlookup can use.
Something like:
VLOOKUP(5,$A$2:B100,COUNT($A$2:A2))
You may need to add a + or - 1 to the count function depending on where your range starts.
It's effectively doing the same thing you already did with the array for the vlookup

Resources