Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Spreadsheets: How to get a first (Nth) row/column from a range? (built-in functions)

Tags:

Say I have this named range, not at A1.

      idz01  idz04  ida02 foo     a      1      b bar     c      3      8 baz     8      2      g 

Now how can I get the first row? And Nth row? And how the Nth column? As a range, using the built-in functions.

Edit: Nth row: =OFFSET(ObjednavkyData, N,0, 1) Last row:

=OFFSET(ObjednavkyData,      MAX(ARRAYFORMULA(ROW(ObjednavkyData)))-ROW(ObjednavkyData), 0, 1  ) 
like image 831
Ondra Žižka Avatar asked Jun 16 '15 01:06

Ondra Žižka


People also ask

How do I do a Hlookup in Google Sheets?

To use the HLOOKUP formula in Google Sheets, ensure that the row you wish to look through is at the top of the formula. Then utilize the formula =HLOOKUP(search-key, range, index, sorted) to look for a specific value in your spreadsheet.

How do you make a column follow a formula in Sheets?

Type the formula you want to use into the top-most empty cell in the column. Hover your cursor over the bottom right of the cell until it changes to a "+" symbol. Click and drag the box down the column until you apply the formula in the empty cell to every cell you require for the calculation.


1 Answers

Just use the INDEX function:

=INDEX(NamedRange1,NRow,NColumn) 

If you want the last row and column you can use:

=INDEX(NamedRange1,ROWS(NamedRange1),COLUMNS(NamedRange1)) 
  • INDEX is more efficient than the alternative OFFSET and INDIRECT that are volatile.

Examples:

=INDEX(ObjednavkyData,3,2) //This will return "c". =INDEX(ObjednavkyData,ROWS(ObjednavkyData),COLUMNS(ObjednavkyData2)) //This will return "g". 

Addition:

If you want to get the whole row, you can omit the column part of the INDEX function. And if you need the whole column, omit the row part (by putting 0 in the row field).

=INDEX(ObjednavkyData,3)    //This will return row 3:    "bar       c      3      8". =INDEX(ObjednavkyData,0, 2) //This will return column 2: "idz01     a      c      8". 
like image 103
dePatinkin Avatar answered Nov 16 '22 02:11

dePatinkin