AI Assistant
Help Center AI Assistant is now available
Got questions about Lark? Use our AI chat to find the answers.
00:00
Click and hold to drag
Got It
Try Now
Use search functions in Sheets

Use search functions in Sheets

13 min read
I. Intro
You can use search functions to search for data in Lark Sheets and process data more efficiently. For example, you can use the COLUMN function to return the column number of a cell.
II. Supported search functions
Function
Description
Syntax
Example
ADDRESS
Returns a cell reference as a string.
ADDRESS(row, column, [absolute or relative mode], [use_A1_notation], [sheet])
  • Formula: ADDRESS(1, 2, 4, FALSE, "Sheet1")
  • Result: The function will return the address of the cell in row 1, column 2 of Sheet 1 using a relative reference and the R1C1 style. The returned result is 'Sheet1'!R[1]C[2].
For more information, see ADDRESS function for Sheets.
AREAS
Returns the number of areas in a reference.
AREAS(reference)
  • Formula: AREAS(B2:D4)
  • Result: Returns the number of areas in B2:D4, which is 1.
For more information, see AREAS function for Sheets.
CHOOSE
Returns an element from a list of choices based on an index.
CHOOSE(index_value,argument1,[argument2,...])
  • Formula: CHOOSE(2, "A", "B")
  • Result: Returns the second value in A and B, which is B.
For more information, see CHOOSE function for Sheets.
CHOOSECOLS
Creates a new array from specified columns.
CHOOSECOLS(array, col_num1, [col_num2], ...)
  • Formula: CHOOSECOLS(A2:B9, 2)
  • Result: Returns the second column of data in A2:B9.
For more information, see CHOOSECOLS function in the next section of this guide.
CHOOSEROWS
Creates a new array from specified rows.
CHOOSEROWS(array, row_num1, [row_num2], ...)
  • Formula: CHOOSEROWS(A2:B9, 2)
  • Result: Returns the second row of data in A2:B9.
For more information, see CHOOSEROWS function in the next section of this guide.
COLUMN
Returns the column number of a specified cell, with A defined as 1.
COLUMN([cell_reference])
  • Formula: COLUMN(C9)
  • Result: Returns the column number of cell C9, which is 3.
For more information, see COLUMN function for Sheets.
COLUMNS
Returns the number of columns in a specified array or range.
COLUMNS(range)
  • Formula: COLUMNS(A2:J10)
  • Result: Returns the number of columns in A2:J10, which is 10.
For more information, see COLUMNS function in the next section of this guide.
DROP
Excludes a specified number of rows or columns from the start or end of an array. This function can be used to remove headers and footers in a spreadsheet to return only the data.
DROP(array, rows,[columns])
  • Formula: DROP(A2:C4,2,2)
  • Result: Excludes the first 2 rows and 2 columns of A2:C4 and returns the value in C4.
For more information, see DROP function in the next section of this guide.
EXPAND
Expands or pads an array to specified rows and columns.
EXPAND(array, rows, [columns], [pad_with])
  • Formula: EXPAND(A2:B3,3,3,3)
  • Result: Expands the values in A2:B3 into an array of 3 rows and 3 columns, and pad empty elements with 3.
For more information, see EXPAND function in the next section of this guide.
FILTER
Returns a filtered version of the source range, containing only rows or columns that meet the specified conditions.
FILTER(range, condition1, [condition2, ...])
  • Formula: FILTER(A2:B26, A2:A26 > 5, B2:B26 < 10)
  • Result: In A2:B26, returns all rows whose value in column A is greater than 5 and whose value in column B is less than 10.
For more information, see FILTER function for Sheets.
FORMULATEXT
Returns a formula as a string.
FORMULATEXT(cell_reference)
  • Formula: FORMULATEXT(A1)
  • Result: Returns the formula in A1 as a string.
For more information, see FORMULATEXT function for Sheets.
GETPIVOTDATA
Extracts an aggregated value from a pivot table that corresponds to the specified row and column headings.
GETPIVOTDATA(value_name, any_pivot_table_cell, [original_column, ...], [pivot_item, ...])
  • Formula: GETPIVOTDATA("AVERAGE price per unit", A1, "region", "east")
  • Result: Returns the average price per unit for the Eastern region in the pivot table where A1 is located.
For more information, see GETPIVOTDATA function for Sheets.
HLOOKUP
Horizontal lookup. Searches across the first row of a range for a key and returns the value of a specified cell in the column found.
HLOOKUP(search_key, range, index, [is_sorted])
  • Formula: HLOOKUP(10003, A2:Z6, 2, FALSE)
  • Result: Searches for 10003 in row 1 of the A2:Z6 range and returns the data in row 2 of the column where 10003 is located.
For more information, see HLOOKUP function for Sheets.
HSTACK
Appends ranges horizontally.
HSTACK(range1; [range2, …])
  • Formula: HSTACK(A2:F9, F10:F15)
  • Result: Merges the values in A2:F9 and F10:F15 horizontally.
For more information, see HSTACK function in the next section of this guide.
IMPORTRANGE
Imports a range of cells from a specified spreadsheet.
IMPORTRANGE(spreadsheet_url, range_string)
  • Result: Returns a reference link to data in A1:D21 of the spreadsheet.
For more information, see IMPORTRANGE function for Sheets.
INDEX
Returns the content of a cell, specified by row and column offset. If more than one area is referenced at the same time, a specific area can be selected.
INDEX(reference, row, [column], [area])
  • Formula: INDEX(A1:C20, 5, 1)
  • Result: Returns the value of the cell at row 5, column 1 in the A1:C20 area.
For more information, see INDEX function for Sheets.
INDIRECT
Returns a cell reference specified by a string.
INDIRECT(cell_reference, [reference style])
  • Formula: INDIRECT("B"&"10", TRUE)
  • Result: Returns the value in cell B10.
LOOKUP
Searches through a sorted row or column for a key and returns the value of the cell in a result range located in the same position as in the search row or column.
LOOKUP(search_key, search_range|search_result_array, [result_range])
  • Formula: LOOKUP(10003, A1:A100, B1:B100)
  • Result: Searches for 10003 in A1:A100 and returns the value in column B of the row where 10003 is located.
For more information, see LOOKUP function for Sheets.
MATCH
Returns the relative position of an item in a range that matches a specified value.
MATCH(search_key, range, [search_type])
  • Formula: MATCH("Sunday", A2:A9, 0)
  • Result: Returns the relative position of Sunday in A2:A9.
For more information, see MATCH function for Sheets.
OFFSET
Returns a reference to a range that is a specified number of rows and columns from a starting cell reference.
OFFSET(cell_reference, offset_rows, offset_columns, [height], [width])
  • Formula: OFFSET(A2, 3, 4)
  • Result: Returns the value of the cell positioned 3 cells down and 4 cells to the right from A2.
For more information, see OFFSET function for Sheets.
ROW
Returns the row number of a specified cell.
ROW([cell_reference])
  • Formula: ROW(A9)
  • Result: Returns the row number of A9, which is 9.
For more information, see ROW function for Sheets.
ROWS
Returns the number of rows in a specified array or range.
ROWS(range)
  • Formula: ROWS(A9: A62)
  • Result: Returns the number of rows in A9:A62, which is 54.
For more information, see ROWS function for Sheets.
SORT
Sorts the elements of a given array or range.
SORT(array, [sort_index], [sort_order], [by_col])
  • Formula: SORT(A2:A17)
  • Result: Sorts the data in A2:A17 in ascending order and returns the sorted data.
For more information, see SORT function for Sheets.
SORTBY
Sorts a range or array based on the values in a corresponding range or array.
SORTBY(array, by_array1, [sort_order1], [by_array2, sort_order2],…)
  • Formula: SORTBY(A2:C20, A2:A20, 1, B2:B20, -1)
  • Result: Cells A2-C20 are sorted first by cells A2-A20 in ascending order, then by cells B2-B20 in descending order.
For more information, see SORTBY function in the next section of this guide.
SORTN
Returns the first n items in a data set after performing a sort.
  • Formula: SORTN(A2:C20, 2, 0, 1, TRUE, 2, FALSE)
  • Result: Sorts the values in A2:C20 in ascending order by column 2 and returns the sorted data from column 2.
For more information, see SORTN function in the next section of this guide.
TAKE
Returns a specified number of contiguous rows or columns from the start or end of an array.
TAKE(array, rows,[columns])
  • Formula: TAKE(A2:C4,2,2)
  • Result: Extracts the first 2 rows and the first 2 columns of data from A2:C4.
For more information, see TAKE function in the next section of this guide.
TOCOL
Transforms an array into a single column.
TOCOL(array_or_range, [ignore], [scan_by_column])
  • Formula: TOCOL(A2:F9, 1, TRUE)
  • Result: Transforms the values in A2:F9 to a single column.
For more information, see TOCOL function in the next section of this guide.
TOROW
Transforms an array into a single row.
TOROW(array_or_range, [ignore], [scan_by_column])
  • Formula: TOROW(A2:F9, 1, TRUE)
  • Result: Transforms the values in A2:F9 to a single row.
For more information, see TOROW function in the next section of this guide.
TRANSPOSE
Transposes the rows and columns of an array or range of cells.
TRANSPOSE(array_or_range)
  • Formula: TRANSPOSE({1,2;3,4;5,6})
  • Result: Transposes the values in {1,2;3,4;5,6}, resulting in {1,3,5;2,4,6}.
For more information, see TRANSPOSE function for Sheets.
VLOOKUP
Vertical lookup. Searches down the first column of a range for a key and returns the value of a specified cell in the row found.
VLOOKUP(search_key, range, index, [is_sorted])
  • Formula: VLOOKUP(10003, A2:B26, 2, FALSE)
  • Result: Searches for 10003 in column 1 of A2:B26 and returns the value in column 2 of the row where 10003 is located.
For more information, see VLOOKUP function for Sheets.
VSTACK
Appends arrays vertically.
VSTACK(range1; [range2, …])
  • Formula: VSTACK(A2:F9, F10:F15)
  • Result: Merges the values in A2:F9 and F10:F15 vertically.
For more information, see VSTACK function in the next section of this guide.
WRAPCOLS
Wraps the provided range by columns after a specified number of elements.
WRAPCOLS(range, wrap_count, [pad_with])
  • Formula: WRAPCOLS(A2:A9, 3, "Pad")
  • Result: Converts the data in A2:A9 into an array of up to 3 rows per column, and pads empty elements with "Pad".
For more information, see WRAPCOLS function in the next section of this guide.
WRAPROWS
Wraps the provided range by rows after a specified number of elements.
WRAPROWS(range, wrap_count, [pad_with])
  • Formula: WRAPROWS(A2:A9, 3, "Pad")
  • Result: Converts the data in A2:A9 into an array of up to 3 columns per row, and pads empty elements with "Pad".
For more information, see WRAPROWS function in the next section of this guide.
XMATCH
Searches for a specified item in an array or range of cells, and then returns the item's relative position.
XMATCH(search_key, lookup_range, [match_mode], [search_mode])
  • Formula: XMATCH(F2, C3:C9, 1)
  • Result: Returns the relative position of the value in F2 in C3:C9.
For more information, see XMATCH function in the next section of this guide.
III. How to use search functions
CHOOSECOLS function
Use the CHOOSECOLS function to create an array from specified columns.
  • Formula: =CHOOSECOLS(array, col_num1, [col_num2], ...).
  • Arguments:
  • array: The array or cell range containing the columns to be returned (for example, A2:B9).
  • col_num1: The first column to be returned. For example, if you enter 2, the data in column 2 of A2:B9 will be returned.
  • col_num2: Additional columns to be returned (optional).
Note: Enter a negative column number to count from the right of the specified array.
  • For example, you can use the CHOOSECOLS function to extract data from non-adjacent columns. In the following example, you can use CHOOSECOLS(A1:D7,1,2) to extract each student's name and their corresponding Chinese language score. A1:D7 denotes the data range, 1 denotes column 1, and 2 denotes column 2.
250px|700px|reset
CHOOSEROWS function
Use the CHOOSEROWS function to create an array from specified rows.
  • Formula: =CHOOSEROWS(array, row_num1, [row_num2], ...)
  • Arguments:
  • array: The array or cell range containing the rows to be returned (for example, A2:B9).
  • row_num1: The first row to be returned. For example, if you enter 2, the data in row 2 of A2:B9 will be returned.
  • row_num2: Additional rows to be returned (optional).
Note: Enter a negative row number to count from the bottom of the specified array.
  • For example, you can use the CHOOSEROWS function to extract data from specific rows. In the following example, you can use CHOOSEROWS(A1:D7,2,3) to extract the exam scores of students A and B. A1:D7 denotes the data range, 2 denotes row 2, and 3 denotes row 3.
250px|700px|reset
COLUMNS function
Use the COLUMNS function to determine the number of columns in a specified array or range.
  • Formula: COLUMNS(range)
  • Arguments:
  • range: The array or range whose column count will be returned (for example, B1:D7).
  • For example, you can use the COLUMNS function to determine the number of columns in a spreadsheet. In the following example, you can use COLUMNS(B1:D7) to calculate the number of subjects in a spreadsheet of exam scores. B1:D7 denotes the range whose column count you want to calculate.
250px|700px|reset
DROP function
Use the DROP function to exclude a specified number of rows or columns from the beginning or end of an array.
  • Formula: DROP(array, rows, [columns])
  • Arguments:
  • array: The array or range from which to exclude rows or columns (for example, A1:D7).
  • rows: The number of rows to exclude. For example, 1 denotes that the first row of data will be dropped from A1:D7.
  • columns: Optional. The number of columns to drop. For example, 1 denotes that the first column of data will be dropped from A1:D7.
Note: A negative value for rows or columns drops from the end of the array.
  • For example, you can use the DROP function to exclude the heading and only return the data. In the following example, you can use =DROP(A1:D7,1) to exclude the heading from a sheet of exam scores.
250px|700px|reset
EXPAND function
Use the EXPAND function to expand or pad an array to specified rows and columns.
  • Function: EXPAND(array, rows, [columns], [pad_with])
  • Arguments:
  • array: The array or range to expand (for example, A2:B3).
  • rows: The number of rows in the expanded array. For example, 3 denotes that the array will be expanded to 3 rows of data.
  • columns: Optional. The number of columns in the expanded array. For example, 3 denotes that the array will be expanded to 3 columns of data.
  • pad_with: Optional. The value with which to pad when the element is empty. The default is #N/A.
  • For example, you can use the EXPAND function to quickly expand a set of data. In the following example, you can use EXPAND(A1:B5,5,8, "Not Registered") to expand the data in a sign-up sheet. After making a few simple edits, you can complete sign-up records for the whole week.
250px|700px|reset
HSTACK function
Use the HSTACK function to merge different ranges of data horizontally.
  • Formula: HSTACK(range1; [range2, …])
  • Arguments:
  • range1: The array or range to append (for example, A2:F9).
  • range2: Optional. Additional ranges to add to range1.
  • For example, you can use the HSTACK function to quickly append data. In the following inventory sheet, you can use HSTACK(A1:C2,A4:B5) to horizontally merge data in A1:C2 and A4:B5.
250px|700px|reset
SORTBY
Use the SORTBY function to sort a range or array based on the values in a corresponding range or array.
  • Formula: SORTBY(array, by_array1, [sort_order1], [by_array2, sort_order2],…)
  • Arguments:
  • array: The array or range to sort (for example, A2:C20).
  • by_array1: The array or range to sort by. For example, A2:A20 denotes that the data should be sorted by column A.
  • sort_order1: Optional. The order to use for sorting. 1 denotes ascending, and -1 denotes descending. The default order is ascending.
  • by_array2: Optional. Additional arrays or ranges to sort by. When there are two or more equal values in the first column, these values will be sorted according to the second column, and so on.
  • sort_order2: Additional orders to use for sorting (optional).
  • For example, you can use the SORTBY function to sort a set of data. In the following example, you can use SORTBY(A2:D7,B2:B7) to sort students by their Chinese exam scores.
250px|700px|reset
SORTN function
Use the SORTN function to obtain the first n items in a sorted data set.
  • Formula: SORTN(array, [n], [display_ties_mode], [sort_column, ...], [is_ascending], ...)
  • Arguments:
  • array: The array or range to sort (for example, A2:C20).
  • n: Optional. The number of items to return. For example, if you enter 2, the first two values will be returned after sorting. n must be greater than 0. If no value is entered, all values will be returned.
  • display_ties_mode: Optional. Determines how identical values are displayed. 0 means return all identical values, 1 means return only the first identical value, and 2 means return only the last identical value. If no value is entered, all identical values will be returned.
  • sort_column: Optional. The column to sort by. For example, 1 denotes that the data should be sorted by the first column. If no value is entered, the data will be sorted by the first column.
  • is_ascending: Optional. The order to use for sorting. False denotes ascending, and True denotes descending. The default order is ascending.
  • For example, you can use the SORTN function to quickly filter the first n values that meet specified conditions. In the following example, you can use SORTN(A2:D7,2,2) to filter the scores for the two top-performing students in the Chinese exam.
250px|700px|reset
TAKE function
Use the TAKE function to obtain a specified number of contiguous rows or columns from the start or end of an array.
  • Formula: TAKE(array, rows,[columns])
  • Arguments:
  • array: The array or range from which to take rows or columns (for example, A2:C4).
  • rows: The number of rows to take. For example, 2 denotes take the first two rows.
  • columns: Optional. The number of columns to take. If no value is entered, all columns will be returned.
Note: A negative value for rows or columns takes from the end of the array.
  • For example, you can use the TAKE function to quickly obtain data from a specified number of rows or columns. In the following example, you can use TAKE(A1:B8,2) to obtain the data from the first two rows in an attendance sheet.
250px|700px|reset
TOCOL function
Use the TOCOL function to transform an array into a single column.
  • Formula: TOCOL(array_or_range, [ignore], [scan_by_column])
  • Arguments:
  • array_or_range: The array or range to transform into a column (for example, A2:F9).
  • ignore: Optional. The data to be ignored. You can specify one or more types of data. 0 means retain all values, 1 means ignore empty cells, 2 means ignore error values, and 3 means ignore other empty cells and error values. If no value is entered, all values will be retained.
  • scan_by_column: Optional. Determines how the array is scanned. Enter True to scan the array by column, or False to scan the array by row. By default, the array is scanned by row.
  • For example, you can use the TOCOL function to quickly transform several columns of data into one column. In the following example, you can use TOCOL(A2:B5,1,FALSE) to transform the data in A2:B5 into one column. You can also use the UNIQUE function to avoid duplicate data.
250px|700px|reset
TOROW function
Use the TOROW function to transform an array into a single row.
  • Formula: TOROW(array_or_range, [ignore], [scan_by_column])
  • Arguments:
  • array_or_range: The array or range to transform into a column (for example, A2:F9).
  • ignore: Optional. The data to be ignored. You can specify one or more types of data. 0 means retain all values, 1 means ignore empty cells, 2 means ignore error values, and 3 means ignore other empty cells and error values. If no value is entered, all values will be retained.
  • scan_by_column: Optional. Determines how the array is scanned. Enter True to scan the array by column, or False to scan the array by row. By default, the array is scanned by row.
  • For example, you can use the TOROW function to quickly transform several columns of data into one row. In the following example, you can use TOROW(A2:B5,1,FALSE) to transform the data.
250px|700px|reset
VSTACK function
Use the VSTACK function to merge different ranges of data vertically.
  • Formula: VSTACK(range1; [range2, …])
  • Arguments:
  • range1: The array or range to merge (for example, A2:F9).
  • range2: Additional ranges to add to range1 (optional).
  • For example, you can use the VSTACK function to quickly merge data. In the following inventory sheet, you can use VSTACK(A1:B5,A7:B8) to vertically merge data in A1:B5 and A7:B8.
250px|700px|reset
WRAPCOLS function
Use the WRAPCOLS function to wrap a range of data by columns with a specified number of cells.
  • Formula: WRAPCOLS(range, wrap_count, [pad_with])
  • Arguments:
  • range: The array or range to wrap (for example, A2:A9). Must be a single row or column.
  • wrap_count: The maximum number of rows for each column. For example, if you enter 2, each column will display a maximum of two rows of data.
  • pad_with: Optional. The value with which to fill the empty cells in the range. By default, empty cells are filled with #N/A.
  • For example, you can use the WRAPCOLS function to wrap data in a single column into multiple columns. In the following example, you can use WRAPCOLS(A2:A5,1) to display the data in A2:A9 in an array of 1 row per column.
250px|700px|reset
WRAPROWS function
Use the WRAPROWS function to wrap a range of data by rows with a specified number of columns.
  • Formula: WRAPROWS(range, wrap_count, [pad_with])
  • Arguments:
  • range: The array or range to wrap (for example, A2:A9). Must be a single row or column.
  • wrap_count: The maximum number of columns for each row. For example, if you enter 2, each row will display a maximum of two columns of data.
  • pad_with: Optional. The value with which to fill the empty cells in the range. By default, empty cells are filled with #N/A.
  • For example, you can use the WRAPROWS function to wrap data in a single row into multiple rows. In the following example, you can use WRAPROWS(A1:E1,1) to display the data in A1:E1 in an array of 1 column per row.
250px|700px|reset
XMATCH function
Use the XMATCH function to search for a specified item in an array or range of cells, and then return the item's relative position.
  • Formula: XMATCH(search_key, lookup_range, [match_mode], [search_mode])
  • Arguments:
  • search_key: The value you want to find. For example, F2 means the function will search for the value in cell F2.
  • lookup_range: The array or range in which to look for values (for example, C3:C9). Must be a single row or column.
  • match_mode: Optional. Enter 0 for an exact match, 1 for an exact match or the next value that's greater, or -1 for an exact match or the next value that's lower. By default, the function will search for an exact match.
  • search_mode: Optional. Enter 1 to search from the first entry to the last, or -1 to search from the last entry to the first.
  • For example, you can use the XMATCH function to quickly find the relative position of a value in a data range. In the following example, you can use XMATCH(D7,A1:A4,0,-1) to find the relative position of the D7 value in A1:A4.
250px|700px|reset
IV. FAQs
How can I merge data from different sheets in the spreadsheet?
You can merge data in the spreadsheet by using one of the following methods:
  • Copy and paste: Copy data from different sheets one by one and paste it into a sheet.
  • IMPORTRANGE function: Use multiple IMPORTRANGE functions in a sheet, with each function referencing data from different sheets. For more details, see IMPORTRANGE function.
  • VSTACK function: Use the VSTACK function in a sheet to vertically append data from different sheets. For more details, see VSTACK function.
  • HSTACK function: Use the HSTACK function in a sheet to horizontally append data from different sheets. For more details, see HSTACK function.
Written by: Lark Help Center
Updated on 2024-11-26
How satisfied are you with this content?
Thank you for your feedback!
Need more help? Please contact Support.
0
rangeDom
rangeDom