The CHOOSECOLS function in Google Sheets is a powerful tool that enables users to extract specific columns from a predefined range. By utilizing this function, users can simplify data manipulation, streamline reporting, and enhance the readability of tables.
Syntax
CHOOSECOLS(range, col_index1, [col_index2, ...])
- range: The range of cells from which columns will be selected.
- col_index1: The index of the first column to include in the new array.
- col_index2: [Optional] The index of additional columns to include.
Example #1
=CHOOSECOLS(A1:D10, 1, 3)
This function selects the first and third columns from the range A1:D10, effectively creating a new array that contains only the specified columns. Result: A new array with data from column A and C, displayed alongside each other.
Example #2
=CHOOSECOLS(E1:H15, 2)
This function retrieves only the second column from the range E1:H15, simplifying the dataset to a single column output. Result: A new array consisting solely of the entries from column F.
Example #3
=CHOOSECOLS(B1:C20, 2, 3)
This example extracts both the second and third columns from B1:C20, generating an array that showcases data from those specific columns. Result: A new array displaying values from columns C and D in rows 1 to 20.
Error handling
- REF!: Occurs if the specified column index exceeds the number of columns in the given range.
- VALUE!: This error appears when the supplied column index is not a valid integer.
- N/A: Indicates that one or more of the provided column indices do not exist within the specified range.