EXCEL GET CELL/ export the data - excel

I have a table that I want to export the data to a table that contains a column of names, dates and attendance so that it takes the values ​​from the table
like this picture

You want INDEX and MATCH. See the formula at this Google Sheet, but it will work the same in Excel This is the top of the two examples:
https://docs.google.com/spreadsheets/d/1bvp6-Jb82A-AEOxvnMLzUNxWUSCKt1merc2nfSt3viE/edit?usp=sharing
=INDEX(F10:M13, match(O13, F10:F13, 0), match(P13, F10:M10, 0))
INDEX takes a range, and two numbers, one for the row and one for the column, and returns the value (or reference) at that intersection. You can pass false or null for either one of the numbers and return the entire row or column of the range, or if you are working with a single dimensional array, like a row or a column, you can just pass one number to it.
MATCH takes a value and a range (and an optional lookup type) and returns the index of that value in the range.
So using INDEX with two MATCHes, you can find the row and column of the data you are looking for.
DOCS:
https://support.microsoft.com/en-us/office/index-function-a5dcf0dd-996d-40a4-a822-b56b061328bd
https://support.microsoft.com/en-us/office/match-function-e8dffd45-c762-47d6-bf89-533f4a37673a
It is possible to do this with VLOOKUP, but I find INDEX/MATCH to be more intuitive and more flexible. Here is a VLOOKUP implementation. It is the bottom of the two examples on the demo sheet:
=vlookup(O16, F10:M13, match(P16, F10:M10, 0))
As you can see, you still pass it the data range and use match to get the column, but VLOOKUP will find the row with the lookup value for you, as long as it is in the first column. INDEX/MATCH lacks this limitation, and I find the arguments more logical: INDEX(range, row, column) vs VLOOKUP(lookup value, range, column).

Related

Sum of index matches for dynamic range of columns

On Sheet2 I am trying to sum the values in a row of a range on Sheet1 over a dynamic range of columns based on a lookup value for the from column and a fixed variable for how many columns to right of that lookup value for the to column.
I am using INDEX-MATCH to find the from cell based on certain reference, INDEX-MATCH with a reference added to the column lookup to find the to column, and CELL to get the position rather than value of the results.
What I have is the following:
=SUM(
CELL("address",
INDEX(Sheet1!$B$4:$BA$36,MATCH($A$1,Sheet1!$A$4:$A$36),MATCH(D$3,Sheet1!$B$3:$BA$3,0)))
&":"&
CELL("address",
INDEX(Sheet1!$B$4:$BA$36,MATCH($A$1,Sheet1!$A$4:$A$36),MATCH(D$3,Sheet1!$B$3:$BA$3,0)+'Control Panel'!$C$2)))
Control Panel!$C$2 is my variable for how many columns to the right of the from column I want the to column to be.
Obviously, this is not working. I suspect it's because the concatenated text in the SUM() reference the full file name rather than 'Sheet1'![from]:[to]. Not sure if this is the case, but also can't figure out how to get just the A1 cell position for the to.
Any ideas how I can get this to work?
Figured it out:
=SUM(INDEX(Sheet1!$B$4:$BA$36,MATCH($A$1,Sheet1!$A$4:$A$36),MATCH(D$3,Sheet1!$B$3:$BA$3,0))):INDEX(Sheet1!$B$4:$BA$36,MATCH($A$1,Sheet1!$A$4:$A$36),MATCH(D$3,Sheet1!$B$3:$BA$3,0)+'Control Panel'!$C$2))
Literally just needed a colon between the two index-matches. Still not sure why this works, as the index-match should return a value.

Excel | Searching table in different sheet and bringing value from column in that row

I am trying to lookup a table in one of my sheets. my table consists of three columns and an unlimited amount of rows.
My table can be seen here:
In my second sheet I wish to write a formula which searches all rows in the table and looks for an exact match in column A and column B, this means it must find the row where column a has a value of "jan" and in that same row the second column must have value "y". Should it find this match, it should return the value of column C.
I tried researching hlookup but that is for horizontal tables so i dont believe this would work. I looked into Vlookups also but that only allows one criteria search instead of looking for two matches.
Can anyone shed some light here please?
You can use index and match with multiple criteria
=INDEX($A$1:$C$1000, MATCH("Jan"&"y", $A$1:$A$1000&$B$1:$B$1000, 0),3)
press CTRL + SHIFT + ENTER when entering this formula.
Convert the range to a table (ctrl-t) and then use SUMIFS to search the table based on two criteria
=SUMIFS(Table1[Alteration],Table1[Month],"Jan",Table1[Products],"y")
This is saying "give me [Alteration] where [Month] = "Jan" and [Products] = 'y'...this returns 364.
You can point the criteria at separate cells containing your criteria.
Be aware that if there is more than one row with identical data (ie more than one row with both 'Jan' and 'y'), column C will be summed together.
The INDEX function has the syntax
INDEX(array, row_num_in_array, [column_num_in_array])
And MATCH returns in the index location of a logic match
MATCH(lookup_value, lookup_array, [match_type])
Combining the two is a flexible technique, and surprisingly powerful -- the logic in a match lookup_value can be a complex condition.
SIMPLEST CODE
Operate on the whole column
INDEX(C:C, MATCH("Jan"&"y", A:A&B:B, 0), 1)
nb./ A:A is excel code for "all of column A". You can instead use:
RESTRICTED CODE
Operates on a subset of the sheet.
INDEX($C$2:$C$1000, MATCH("Jan"&"y", $A$2:$A$1000&$B$2:$B$1000, 0), 1)
Note that you MUST use identical row length arrays (eg. rows 2:1000) or the formula will not work. MATCH only knows how many rows into its lookup_array it got, you need to ensure its rows match those in INDEX's array
PS. apologies this is close to the previous answer, but the details were too long for a comment.
PPS. I missed the clarifications to the first answer. That will work, but there is no need to use all three columns as the array in the INDEX function. You are only returning data from column C after all.

vlookup on array with variable number of rows

I'm trying to use the approximate match function of vlookup to find a value in an array, that can be of different length. I just dragged the lookup array as far down as possible in order to assure that all data is selected, however, the approximate match option will then always select the last value in the array. Is there a way of feeding vlookup the correct lookup array in order to extract the correct value? Regards
Create a dynamic range name and feed that into the Vlookup. For example, if your lookup table starts in A1 and has numeric data, define a name called TheRange with the formula
=Sheet1!$A$1:Index(Sheet1!$D:$D,match(99^99,Sheet1!$A:$A,1))
This will return a range from A1 to column D down to the last row with a number in column A. When rows are added or removed from the table, the named range will be recalculated automatically and adjust to the new dimensions.
Then can use
=vlookup(YourValue,TheRange,2,1)
Adjust cell addresses to your situation. I take it you are aware that for an approximate match the data must be sorted ascending for the formula to return the correct result. With the 1 or TRUE as the last parameter, the formula will always return a result, but if the table is not sorted on the first column, the result is most likely not correct.

Excel How can I direct columns by their headline?

Currently I have a huge formula in my excel sheet:
=SUM(SUMIF(INDIRECT(A9&"!$F:$F"),"working";INDIRECT(A9&"!$B:$B"))+SUMIF(INDIRECT(A9&"!$F:$F");"Open";INDIRECT(A9&"!$B:$B"))+SUMIF(INDIRECT(A9&"!$F:$F");"internal",INDIRECT(A9&"!$B:$B"))+(SUMIF(INDIRECT(A9&"!$F:$F"),"finished";INDIRECT(A9&"!$AP:$AP"))))
In A9 is the name of the excel sheet that the formula has to use. So for example in A3 there's '20140612', so it has to use the excel sheet with the name '20140612'. Furthermore it sums up some values depending on some conditions.
My question is: I would like to direct the columns in the other sheets by their headlines, not their positions in the sheet. So for example le column AP doesn't always has to be in the position AP, but has always the headline 'Points'.
Can you think of an adaption of the formula that can direct the column by their headline?
I though of the MATCH formula. But I'm not to sure where I have to put this in.
I think the simplest answer would be to use named ranges within your sheet. In this way you could name a range (currently in column AP) as 'Points', change your formula to use 'Points' instead of '$AP:$AP' & if you move your points data about the formulas would be unchanged.
If you are planning to keep changing your header row values then you could use HLOOKUP to match up the header column probably in conjunction with MATCH & INDEX.
To answer your question about the usage of MATCH(), it's worth thinking of it as half of a VLOOKUP() or HLOOKUP(), i.e. it's the bit that finds the row or column containing the value you're searching for, then you can use INDEX() to get that row / column from a range you specify.
So, if you know that one of your column headings is "Points", then you could find it by using:
=MATCH("Points", A1:Z1, FALSE)
...which would return 10 if "Points" were the heading of column J for example. If you wanted to then use that column for a lookup, you can use OFFSET() to define that column as a range to use for a lookup, so let's say I wanted to find the text "foo" in the "Points" column, I could use:
=MATCH("foo", OFFSET(A1:Z1000, 0, MATCH("Points", A1:Z1, FALSE) - 1, 1000, 1), false)
... which uses the column index I found before as an input to OFFSET() in order to dynamically reference J1:J1000 and then search for "foo" in that column.
For your example in the question, rather than A1:Z1000 you could use a call to INDIRECT() that would return the entire range of interest from your source sheet.

Select a cell value from a range based on criteria

I'm trying to figure out a sleeker method for determining the value of a cell based on criteria defined in a given range. To put it bluntly, I have a column for standard viscosity, standard temperature, and measured temperature. I'm needing to create a fourth column that will select the standard viscosity based on the measured temperature. For example, if measured temperature is greater than or equal to 0oC and less than 1oC: return standard viscosity for 0oC.
My issue is that I have a large range and find it to tedious to create a custom expression for each range. I've created a nightmarish function that was composed of IF(AND()) statements but find this exhausting, especially if I try to create an expression for a 0-200oC scale in single digit increments.
Here is a sample of a code that works but is quite cumbersome:
=IF(AND(G8>=$C$7,G8<$C$8),$D$7,0)+IF(AND(G8>=$C$8,G8<$C$9),$D$8,0)+....
or
=IF(AND(measured temp>=0,measured temp<1),$D$7,0)+IF(AND(measured temp>=1,measured temp<2),$D$8,0)
How could I approach this in a sleeker manner?
You can achieve this by the VLOOKUP function.
=VLOOKUP(G8;$C$7:$D$...;2;TRUE)
Replace the three dots with the index of the last row of your table.
The first argument of VLOOKUP is the value to search for; the second argument is the range whose first column is to be searched for the value; the third argument is the index of the column containing the values to return (within the range, so 2 means the second column within the range, which is D in your case); TRUE means that you do not want to search for an exact match, but that the column to be search is an ordered list of values defining intervals.
Edit:
With MATCH and OFFSET (guessed, not tried), if column with result values is left relative to column of criterion values:
=OFFSET($C$7;...;MATCH(G8;$C$7:$C$...;1) - 1)
Replace the first three dots with the position of the result column, relative to column C (so 1 if it's column D, and -1 if it's column B), and the second three dots with the index of the last row of your range, as above.
Edit2:
INDEX instead of OFFSET is even better, se pnuts's answer and the comment below:
=INDEX($D7:$D...;MATCH(G8;$C$7:$C$...;1))
If your measured temperature is say in F2 and your data table is A:C please try:
=INDEX(A:A,MATCH(F2,C:C))

Resources