Last active
December 8, 2024 20:25
-
-
Save ExcelRobot/4f75861ff3178026424fba8f215a8cba to your computer and use it in GitHub Desktop.
Indirect Expand Lambda
This file contains hidden or 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: Indirect Expand (IndirectExpand) | |
Description: Converts a range address (and optional sheet name) to a reference to those cells and the cells surrounding them by a user specified distance. | |
Parameters: | |
address - range address text | |
[sheet_name] - name of sheet, if not active sheet | |
[expand_distance] - number of cells in all directions to expand the selection (default: 0) | |
Source: @ExcelRobot | |
*/ | |
IndirectExpand =LAMBDA(address, [sheet_name], [expand_distance], LET( | |
\\LambdaName, "IndirectExpand", | |
\\CommandName, "Indirect Expand", | |
\\Description, "Converts a range address (and optional sheet name) to a reference to those cells and the cells surrounding them by a user specified distance.", | |
\\Parameters, { | |
"address","range address text"; | |
"[sheet_name]","name of sheet, if not active sheet"; | |
"[expand_distance]","number of cells in all directions to expand the selection (default: 0)" | |
}, | |
\\Source, "@ExcelRobot", | |
_Prefix, IF( | |
ISOMITTED(sheet_name), | |
"", | |
"'" & SUBSTITUTE(sheet_name, "''", "'") & "'!" | |
), | |
_Address, _Prefix & address, | |
_Result, IF( | |
ISOMITTED(expand_distance), | |
INDIRECT(_Address), | |
OFFSET( | |
INDIRECT(_Address), | |
-expand_distance, | |
-expand_distance, | |
ROWS(INDIRECT(_Address)) + 2 * expand_distance, | |
COLUMNS(INDIRECT(_Address)) + 2 * expand_distance | |
) | |
), | |
_Result | |
)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment