=IF(A1<10, IF(A1>2, SUM(B1:B5), 0), SUM(B2:B6))
=LET(
input1, A1,
input2, B1:B5,
input3, B2:B6,
IF(input1<10, IF(input1>2, SUM(input2), 0), SUM(input3)))
Also handles the "messy LET" case: extracts refs from inside calculation bindings, merges duplicate value bindings (first name wins), and reorders inputs-before-steps.
4 PR-sized slices, sequenced. PR 1 is a tracer bullet — end-to-end on non-LET formulas with cell refs / ranges / spill — so the feature is exercisable in Excel from day one.
Overview
New
/Refactorslash command that takes the active cell's formula — LET or not — and rewrites it as a tidy LET where every cell ref and range appears as a single value binding. The author then runs/LET to LAMBDAas the next step. Mirrors the/Gather → /LET to LAMBDAtwo-stage pattern.Worked example
Active cell:
After
/Refactor:Also handles the "messy LET" case: extracts refs from inside calculation bindings, merges duplicate value bindings (first name wins), and reorders inputs-before-steps.
Spec and plan
Implementation Plan
4 PR-sized slices, sequenced. PR 1 is a tracer bullet — end-to-end on non-LET formulas with cell refs / ranges / spill — so the feature is exercisable in Excel from day one.