Community生產力與協作github.com

andreworia/sensitivity-tables

在 .xlsx 檔案中建立單變數與雙變數敏感度分析(資料表),保留即時公式並執行重新計算驗證,最後交付完整活頁簿。

sensitivity-tables 是什麼?

此技能專為策略或財務模型設計,當模型有一個關鍵輸出(如 NPV、IRR、EPS、邊際利潤)且需要觀察此輸出如何隨一或兩個輸入變數(如價格、數量、折現率、成長率、客戶流失率或單位成本)變動時使用。它會在 Claude 應用程式中從頭建立一個可下載的 .xlsx 檔案,使用 openpyxl 和 numpy 生成,包含即時公式與重新計算驗證步驟。支援單變數與雙變數資料表結構,並提供原生 Excel 資料表(`{=TABLE(r,c)}` 陣列公式)與 Python 程式計算的備用矩陣兩種方式。此外,它會套用三色色階、添加驗證檢查區塊,並透過 headless LibreOffice 重新計算活頁簿以確保公式無誤,最後交付乾淨的 .xlsx 檔案。請注意,此技能不適用於 Claude for Excel 附加元件編輯既有活頁簿的情境。

相容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/andreworia/claude-excel-skills/tree/main/skills/sensitivity-tables

Installed? Explore more 生產力與協作 skills: steipete/gemini, steipete/gh-issues, steipete/skill-creator · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

敏感度分析表(單變數與雙變數)

使用時機

當策略或財務模型有一個關鍵輸出,且您希望展示該輸出如何隨著一或兩個驅動因子在範圍內變動時使用。典型的驅動因子包括價格、數量、折現率、成長率、客戶流失率或單位成本。此技能會在 Claude 應用程式(使用 openpyxl 與 numpy)中從頭建立一個可下載的 .xlsx 檔案,包含即時公式與重新計算驗證步驟。這不是 Claude for Excel 附加元件。

建立的內容

建立一個名為 Sensitivity 的工作表,附加於既有模型。它會參照模型的輸入儲存格與輸出儲存格,佈置單變數與雙變數網格,並對結果區塊套用色階。若來源模型位於其他工作表,網格會透過跨工作表參照與之連結,以保持即時性。

建置工作流程

  1. 識別輸出儲存格(例如 Model!B40 存放 NPV)以及一或兩個驅動它的輸入儲存格(例如 Model!B6 折現率、Model!B7 成長率)。
  2. 確認輸出是透過公式鏈接回這些輸入的即時公式。若輸出是手動輸入的固定值,則停止作業,先建立模型;對固定值執行資料表只會傳回該固定值。
  3. 選擇基礎案例周圍的輸入範圍(例如基礎折現率為 10%,掃描範圍 6% 至 14%,步長 2%)。
  4. 建立原生 Excel 資料表結構:角落公式、輸入軸,以及 {=TABLE(r,c)} 陣列(詳見規格)。
  5. 也建立程式計算的備用網格作為穩健後備方案:在 Python 中針對每個輸入組合重新評估模型,並將結果值寫入標記好的矩陣。
  6. 對結果區塊套用三色色階,並用輸入儲存格名稱標示兩個軸。
  7. 添加驗證檢查區塊。
  8. 在真實引擎(headless LibreOffice)中重新計算活頁簿。
  9. 驗證零公式錯誤(#REF!、#DIV/0!、#VALUE!、#NAME?),確認檢查通過,然後交付 .xlsx。

各工作表規格

敏感度工作表:單變數區塊

選擇佈局方向。以輸入值向下填入欄為例:

  • B3:輸出公式,參照即時輸出:=Model!B40。這是角落儲存格。
  • A4:A10:要掃描的輸入值(藍色輸入),例如 6%、8%、10%、12%、14%。
  • B4:B10:資料表結果欄。
  • 選取 A3:B10,然後「資料」>「假設分析」>「資料表」,將「列輸入儲存格」留空,並將「欄輸入儲存格」設為 Model!B6。Excel 會將 {=TABLE(,Model!B6)} 寫入 B4:B10。
  • openpyxl 可以將陣列公式字串 =TABLE(,Model!B6) 寫入區塊,並將 =Model!B40 寫入角落,但數值只有在透過真實引擎重新計算後才會填入。

相同區塊的程式計算備用方案(建議在透過程式碼生成時使用),寫入下方標記的矩陣,例如從 A14 開始:

  • A14:標籤「折現率」。B14:標籤「NPV(計算值)」。
  • 對於 A15:A21 中的每個輸入值,Python 將 Model!B6 設為該值,在 numpy 中重新計算模型邏輯,並將結果 NPV 以純數值寫入 B 欄。
  • 兩者並存:原生資料表證明它為即時;計算矩陣則保證即使使用者尚未開啟 Excel 也能看到填入的數字。

敏感度工作表:雙變數區塊

  • 角落儲存格 E3:=Model!B40(即時輸出)。
  • E4:E10:向下填入左側邊緣的列輸入值(第一個驅動因子,例如成長率 0%、1%、… 6%)。
  • F3:L3:橫向填入頂端列的欄輸入值(第二個驅動因子,例如折現率 6% … 14%)。
  • 選取 E3:L10,「資料」>「假設分析」>「資料表」,將「列輸入儲存格」設為 Model!B7(橫向驅動因子),「欄輸入儲存格」設為 Model!B6(向下驅動因子)。Excel 會以 {=TABLE(Model!B7,Model!B6)} 填入 F4:L10。
  • 注意方向:與頂端列連結的儲存格放入「列輸入儲存格」;與左側欄連結的儲存格放入「欄輸入儲存格」。互換兩者會無聲地將結果轉置。
  • 程式計算備用方案:在 Python 中以雙層迴圈遍歷兩個軸,將數值矩陣寫入標記好的區塊(若軸值從模型提取則軸標題用綠色,若為文字掃描值則用藍色)。

選擇軸範圍

  • 將每個軸對齊基礎案例值,使基礎值位於中間列與中間欄,這樣中心儲存格的檢查才有意義。
  • 使用奇數個步階(5、7 或 9),以便單一中間儲存格恰好對齊基礎案例值,而非落在兩個儲存格之間。
  • 在每個軸上保持步長均勻(固定增量),使網格呈現清晰的漸變,並讓色階易於解讀。
  • 對於比率,以絕對點數掃描(8%、10%、12%),而非基礎值的相對百分比,以避免混淆讀者。

openpyxl 建置注意事項

  • 將角落寫入為真實公式字串:ws["B3"] = "=Model!B40"。請不要貼上輸出當前的數值。
  • 對於原生資料表陣列,openpyxl 可以儲存 =TABLE(...) 文字,但必須由真實引擎重新計算才能填入區塊;請將陣列視為佔位符,直到重新計算步驟執行。
  • 在寫入程式計算備用方案時,使用 Python 設定資料值(ws.cell(row=r, column=c, value=float(npv))),並透過標頭註記(例如「計算快照」)使其與即時區塊在視覺上有所區別。
  • 使用 openpyxl.formatting.rule.ColorScaleRule 對結果區塊套用色階,透過中點將最小值映射至一種顏色、最大值映射至另一種顏色。

公式與格式慣例

  • 輸入值(手動輸入的軸掃描值)使用藍色字型。
  • 工作表內公式使用黑色字型。
  • 跨工作表連結(例如 =Model!B40)使用綠色字型。
  • 不應在應放置公式的位置使用手動輸入值:角落儲存格必須是 =Model!B40,絕不能是手動輸入的基礎案例數字。
  • 每列或每欄使用一致的一個公式:整個資料表區塊是一個單一陣列;計算備用方案則使用單一 Python 表達式套用至整個網格。
  • 數字格式:比率使用 0.0%,貨幣輸出使用 #,##0,比值使用 0.00。軸數值格式應與其所取代的輸入儲存格單位一致。

檢查項目

  • 角落儲存格等於即時輸出:=(B3=Model!B40) 應傳回 TRUE。
  • 軸已標示輸入儲存格名稱(在每個軸上方或旁側放置文字標籤,標明驅動因子名稱及其儲存格位址)。
  • 網格中心與基礎案例相符:位於基礎案例列與基礎案例欄的網格儲存格應等於模型當前輸出,=(<中心儲存格>=Model!B40) 為 TRUE。
  • 對於計算備用方案,基礎輸入位置的值應等於原生資料表在同一輸入位置的值(在四捨五入誤差範圍內)。

重新計算與驗證

使用 openpyxl 儲存後,以 headless 模式重新計算(例如 libreoffice --headless --convert-to xlsx),使 =TABLE(...) 與跨工作表連結填入數值。重新載入並掃描每個儲存格是否有 #REF!、#DIV/0!、#VALUE!、#NAME? 錯誤。確認三項檢查皆傳回 TRUE。若出現任何錯誤或 FALSE,請修正參照或範圍並循環重複,直到乾淨為止,然後交付。

需收集的輸入項目

  • 來源模型的路徑與精確的輸出儲存格位址。
  • 要掃描的一或兩個輸入儲存格位址。
  • 基礎案例值以及每個軸的期望範圍與步長。
  • 軸與輸出的單位與偏好的數字格式。

範例

假設模型:Model!B40 = 專案 NPV,由 Model!B6 折現率(基礎 10%)和 Model!B7 營收成長率(基礎 3%)驅動。單變數區塊掃描折現率 6% 至 14%,步長 2%,得到(假設單位)NPV 為 1,210 / 980 / 760 / 560 / 380。雙變數區塊將成長率 0% 至 6% 與折現率 6% 至 14% 交叉;位於成長率 3% 與折現率 10% 的中心儲存格等於 Model!B40 的 760,確認基礎案例位於網格中央。

Individual skills in this repo

This repo contains 11 individual skills — each has its own dedicated page.

andreworia/assumption-registry-builder

Creates a structured assumption register for any Excel model with columns for name, category, base value, source, Bull/Bear values, sensitivity rank, and owner, plus a formula for computing sensitivity rank from Data Table outputs.

andreworia/data-cleaning-for-excel

Turns pasted or exported data with mixed formats, blank rows, or duplicates into a clean, consistently formatted range ready for analysis. Use it right after pasting raw data into a worksheet.

andreworia/formula-audit-checker

Provides a systematic audit checklist for Excel model formula logic, hardcoded values, circular references, and error handling, with step-by-step instructions for using Excel's native auditing tools.

andreworia/inputs-calcs-outputs-design

Enforces the three-tab separation principle for any Excel model, producing a full design for a dedicated Inputs tab, one or more Calculations tabs, and a clean Outputs tab with a conventions checklist.

andreworia/model-architecture-template

Defines the master tab structure, naming conventions, color codes, number formats, and print area setup for any new strategy or finance Excel model, serving as the structural template before any content is added.

andreworia/output-summary-tab

Designs the executive summary tab of an Excel model with KPI tiles, a narrative block, a sensitivity summary, and an assumption log, formatted for print or screenshot use in a board pack.

andreworia/pivot-table-builder

Specifies and builds a pivot table from a flat data range, choosing rows, columns, values, and filters. Use it when you have raw tabular data and need a summary view without building it cell by cell.

andreworia/revenue-build

Builds a driver-based revenue forecast .xlsx with live formulas across separate drivers, build, and output tabs plus checks, rolling a customer or units schedule (beginning, adds, churn, ending) into revenue with Base/Bull/Bear scenario toggles. Use when someone needs a bottom-up revenue model, an ARR build, or a driver-based forecast for planning or a board deck. Do not trigger for editing an existing workbook through the Claude for Excel add-in.

andreworia/scenario-manager

Builds a Base/Bull/Bear scenario switching layer for a model in a .xlsx with a live selector, CHOOSE or INDEX assumption links, a side-by-side output comparison, and a recalc check, then delivers the workbook. Use when someone wants an auditable scenario toggle instead of Excel's hidden Scenario Manager. Do not trigger for editing an existing workbook through the Claude for Excel add-in.

andreworia/sensitivity-tornado

Ranks variable sensitivities to a key output and builds a tornado chart by swinging each input over a defined range, computing output impact, and producing a horizontal bar chart data structure.

andreworia/unit-economics

Builds a unit-economics and cohort .xlsx with live formulas across separate assumptions, cohort, and output tabs plus checks, computing CAC, LTV, LTV/CAC, and CAC payback from a monthly cohort retention grid. Use when someone needs unit economics, an LTV/CAC analysis, a payback model, or a cohort retention build. Do not trigger for editing an existing workbook through the Claude for Excel add-in.

相關技能