Last active
May 14, 2024 01:37
-
-
Save ExcelRobot/e54ef43a981362c0b414ee27cf3e0fcb to your computer and use it in GitHub Desktop.
Choose Table Columns LAMBDA Function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Name: Choose Table Columns (CHOOSETABLECOLUMNS) | |
Description: Similar to CHOOSECOLUMNS but can accept an array of column header names or | |
array of column indexes. If column headers are used, assumes first row of Table is | |
header row. | |
Author: Excel Robot (@ExcelRobot) | |
Category: Table | |
*/ | |
CHOOSETABLECOLUMNS = LAMBDA(Table, ColumnsToSelect, LET( | |
FirstColumnToSelect, INDEX(ColumnsToSelect,1,1), | |
ColumnIndexes, IF( | |
AND(ISNUMBER(FirstColumnToSelect),IFERROR(AND(FirstColumnToSelect>0,FirstColumnToSelect<=COLUMNS(Table),TRUNC(FirstColumnToSelect)=FirstColumnToSelect), | |
FALSE)), | |
ColumnsToSelect, | |
MATCH(ColumnsToSelect,INDEX(Table,1,),0)), | |
SelectedColumns, INDEX(Table,SEQUENCE(ROWS(Table)),ColumnIndexes), | |
SelectedColumns | |
)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment