Refactor repeated Excel calculations with LET

작성자: AILesson6 분 소요테스트::ChatGPT검토일: 2026-08-28

빠른 답변

Name repeated expressions once, preserve workbook behavior, and verify that the refactor is equivalent. 제공할 내용: Current formula, Intended behavior and workbook context, Compatibility and test cases. 예상 결과: A readable LET formula with dependency map, equivalence tests, and compatibility fallback.

1

맥락 추가

텍스트는 이 브라우저에 유지됩니다. AILesson Prompts는 이를 모델이나 서버로 보내지 않습니다.

2

프롬프트

채워지지 않은 필드는 플레이스홀더로 표시되므로 프롬프트를 복사하고 편집할 수 있습니다

Refactor the Excel formula with LET only where naming an expression improves reuse, readability, or calculation cost.

Exact formula and first cell:
[formula]

Headers, names, repeated operations, blank/error behavior, copying, and refactor goal:
[intent]

Versions/platforms, separators, performance, samples, and expected edge results:
[environment]

Parse the formula before changing it. Identify repeated calculations, stable inputs, intermediate values, volatile or array operations, short-circuit assumptions, and error boundaries. Create valid Excel variable names that communicate business meaning, avoid cell-like names and name collisions, and define each value before use. Preserve reference anchoring, evaluation meaning, blank/text/date behavior, error handling, and final type; do not hide a defect merely to produce a cleaner LET. If LET is unsupported in any required environment, provide the original or another compatible fallback. Return: behavior summary; repetition and dependency map; refactored formula; name-by-name explanation; exact changes and preserved behavior; compatibility note; performance claim limited to what can be inferred; and equivalence tests covering normal, blank, zero, error, boundary, and copy-down cases.
Playground에서 사용해 보기
기본적으로 비공개프롬프트 구성은 브라우저에서 로컬로 이루어집니다. 조직에서 허용하지 않는 한 기밀 정보를 AI 서비스에 입력하지 마세요.

입력에서 결과까지

적용 예시

구체적인 맥락이 이 레시피를 바로 사용할 수 있는 결과로 바꾸는 방법을 확인하세요

실제 입력

Current formula
In Sales!H2: =IF(B2="","",IFERROR(IF(XLOOKUP(B2,Products!$A$2:$A$2000,Products!$D$2:$D$2000,0)>0,ROUND(E2*XLOOKUP(B2,Products!$A$2:$A$2000,Products!$D$2:$D$2000,0),2),0),"Review"))
Intended behavior and workbook context
B is Product ID, E is quantity, H is line value. Products A is unique Product ID and D is unit price. Blank product ID returns blank; unknown ID should return Review, not zero. A real zero price returns 0. Formula copies down 20,000 rows. XLOOKUP is repeated twice. Preserve fixed source ranges and relative B/E. Existing formula may have a defect because XLOOKUP's not-found argument is 0, which could make unknown IDs look like a real zero price.
Compatibility and test cases
Microsoft 365 desktop and web only; LET and XLOOKUP supported. Comma separators. Tests: P-10, quantity 3, price 12.50 -> 37.50; P-FREE, quantity 2, price 0 -> 0; unknown P-99 -> Review; blank B -> blank; quantity text ‘three’ -> Review; copy to row 3 uses B3/E3. No measured performance baseline.

예시 출력

Behavior audit: the current formula repeats the same exact lookup twice, but it does not meet the stated unknown-ID rule. Its XLOOKUP returns 0 when no key is found, and the outer comparison then treats that as a legitimate zero price. A behavior-preserving LET would preserve this defect, so the correction must be called out separately.

Corrected LET formula for H2: =IF(B2="","",LET(productId,B2,quantity,E2,unitPrice,XLOOKUP(productId,Products!$A$2:$A$2000,Products!$D$2:$D$2000,NA(),0),IFERROR(IF(unitPrice>0,ROUND(quantity*unitPrice,2),0),"Review"))). productId and quantity document relative row inputs; unitPrice performs one exact lookup against fixed source ranges. NA() ensures an unknown key reaches IFERROR, while an actual numeric zero still returns 0. The intentional behavior change is unknown ID: 0 → Review. Blank, real zero, rounding, and input-error behavior are preserved.

Compatibility: valid for the stated Microsoft 365 environments; retain the corrected non-LET form only if a future recipient lacks LET. Performance may improve because one lookup replaces two per nonblank row, but no runtime percentage can be claimed without measuring the workbook.

Equivalence/correction tests: P-10 ×3 → 37.50 in corrected old and LET versions; P-FREE ×2 → 0; P-99 → Review (deliberate fix); blank ID → blank without lookup; quantity “three” with valid positive price → Review; copy to H3 changes productId/quantity to B3/E3 while Products ranges remain fixed. Also verify duplicate product IDs separately before trusting any single-result lookup.

효과가 있는 이유

  1. 1

    A dependency map prevents repeated text from being merged when the references or error boundaries are not actually equivalent.

  2. 2

    Equivalence tests make readability improvements accountable to unchanged workbook results.

결과 확인

  • Does each LET name represent one repeated or conceptually important value and obey Excel naming rules?

  • Are absolute, mixed, structured, and relative references preserved when copied?

  • Do original and refactored formulas match on normal and edge-case test rows?

안심하고 사용하세요

자주 묻는 질문

이 레시피를 언제 사용해야 하는지, 무엇을 제공해야 하는지, 그리고 어떤 부분에서 사람의 검토가 여전히 중요한지에 대한 실용적인 답변

What should I prepare before using “Refactor repeated Excel calculations with LET”?

For “Refactor repeated Excel calculations with LET,” prepare Current formula, Intended behavior and workbook context, and Compatibility and test cases. Replace placeholders only with information you can verify. If a detail is unknown, preserve that uncertainty explicitly instead of asking the model to infer it.

When is the “Refactor repeated Excel calculations with LET” result not ready to use?

The result is not ready if it does not yet deliver the stated outcome—A readable LET formula with dependency map, equivalence tests, and compatibility fallback—from the supplied evidence, or if it relies on unresolved assumptions, missing approvals, or invented details. Use the checks as release gates: revise the source inputs or assign a named, authorized reviewer instead of polishing an unsupported output.

Which AI tools have recorded tests for “Refactor repeated Excel calculations with LET”?

The published test record for “Refactor repeated Excel calculations with LET” lists ChatGPT as of 2026-08-28. This confirms recorded runs, not guaranteed compatibility or identical results in later product versions. For another tool or version, keep every constraint visible and repeat the result checks before use.

더 많은 탐색 방법

이 레시피가 적합한 상황

작업을 계속 진행하세요