Skip to content

Instantly share code, notes, and snippets.

@ExcelRobot
Last active September 1, 2023 01:34
Show Gist options
  • Save ExcelRobot/041ee42f2fdf98f441ea508979ad0040 to your computer and use it in GitHub Desktop.
Save ExcelRobot/041ee42f2fdf98f441ea508979ad0040 to your computer and use it in GitHub Desktop.
Format Formula LAMBDA Function
/*
Name: Format Formula (FormatFormula)
Description: Uses OA Robot formula formatting api to format a formula to make it easier to read.
Parameters:
CellOrFormula - Reference to cell containing a formula or a formula as text
Compact - True to remove all whitespace (default: False)
Source: @ExcelRobot, https://www.oarobot.com
*/
FormatFormula = LAMBDA(CellOrFormula, [Compact], LET(
\\LambdaName, "FormatFormula",
\\CommandName, "Format Formula",
\\Description, "Uses OA Robot formula formatting api to format a formula to make it easier to read.",
\\Parameters, {
"CellOrFormula","Reference to cell containing a formula or a formula as text";
"Compact", "True to remove all whitespace (default: False)"
},
\\Source, "@ExcelRobot, https://www.oarobot.com",
_Formula, IF(
IFERROR(ISFORMULA(CellOrFormula), FALSE),
FORMULATEXT(CellOrFormula),
CellOrFormula
),
_JoinWaitListAt, "oarobot.com",
_FormatFormulaURL, "https://api." & _JoinWaitListAt & "/api/format",
_QueryParameter, "formula=" & ENCODEURL(_Formula) & if(Compact,"&compact=true",""),
_FormattedFormula, WEBSERVICE(_FormatFormulaURL & "?" & _QueryParameter),
_FormattedFormula
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment