Community生產力與協作github.com

andreworia/情境管理員

在 .xlsx 模型中建立 Base / Bull / Bear 情境切換層,包含即時選擇器、使用 CHOOSE 或 INDEX 的假設連結、並排輸出比較與重新計算檢查,然後交付活頁簿。當使用者想要一個可稽核的情境切換功能,而非 Excel 內建的隱藏式「情況管理員」時使用。請勿在透過 Claude for Excel 增益集編輯現有活頁簿時觸發。

情境管理員 是什麼?

這個技能會從頭建立一個可下載的 .xlsx 活頁簿,內建 Base、Bull、Bear 三種情境的切換層。它透過 openpyxl 與資料驗證在 Claude 應用程式中建構,包含一個即時下拉選擇器(Cover 頁籤)、一個存放所有情境假設值的「情境輸入」頁籤、以及使用 CHOOSE 或 INDEX 函數將選擇器連結到模型假設公式的機制。此外,還有一個「輸出」頁籤能以並排方式即時比較三種情境的關鍵結果(例如營收、EBIT、NPV),以及一個「檢查」頁籤來驗證選擇器範圍、假設完整性與公式正確性。建置完成後會透過無頭 LibreOffice 進行重新計算,並掃描 #REF!、#DIV/0! 等錯誤,確保活頁簿可立即使用。與 Excel 內建的「情況管理員」相比,這個設計讓所有情境值與公式都顯示在工作表上,更具可稽核性,適合用於財務模型、商業規劃或任何需要官方級情境分析的場景。

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

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

在你喜歡的 AI 中提問

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

說明文件

情境管理員 (Base / Bull / Bear)

使用時機

當模型需要在 Base、Bull、Bear 三種情境間乾淨切換,且這些情境由少數假設驅動時使用。您希望所有情境在單一工作表上一目了然且可稽核。此技能在 Claude 應用程式中從頭建立一個可下載的 .xlsx 活頁簿(使用 openpyxl 加上資料驗證),包含即時選擇器、公式驅動的假設擷取、比較表格,以及重新計算與驗證步驟。這並非 Claude for Excel 增益集。

建立的內容

五個區域:Cover 頁籤(選擇器與摘要)、Scenario Inputs 頁籤(每個驅動因子在 Base、Bull、Bear 下的值)、連結到模型內的即時連結(使假設擷取作用中情境)、Outputs 比較頁籤(所有三種情境的關鍵結果並排顯示),以及 Checks 頁籤。

建置工作流程

  1. 列出在不同情境間有差異的驅動因子(例如成長率、價格、流失率、資本支出),並在模型中找出每個驅動因子的假設儲存格。
  2. 建立存放每個驅動因子之 Base、Bull、Bear 值的 Scenario Inputs 區塊。
  3. 建立一個單一選擇器儲存格(值為 1、2 或 3),並加上資料驗證下拉選單。
  4. 重寫每個模型假設儲存格,使其透過 CHOOSE 或 INDEX 參考選擇器來擷取作用中情境的值。
  5. 建立 Outputs 頁籤,比較所有三種情境的關鍵結果(並行計算,請見規格),如此無論選擇器設定為何,所有情境都能同時顯示。
  6. 加入 Checks 頁籤。
  7. 在真實的試算表引擎(無頭 LibreOffice)中重新計算活頁簿。
  8. 驗證無任何公式錯誤(如 #REF!、#DIV/0!、#VALUE!、#NAME?),確認所有檢查通過,然後交付 .xlsx。

逐頁籤規格

Cover 頁籤

  • B2:選擇器儲存格。套用資料驗證清單 1,2,3(或命名清單 Base、Bull、Bear,對應到 1/2/3)。
  • B3:作用中情境名稱,=CHOOSE(B2,"Base","Bull","Bear")。
  • 一個小型的結果摘要,讀取作用中情境下的即時模型輸出,例如 B6 =Model!B40。

Scenario Inputs 頁籤

每個驅動因子一行,每個案例一欄:

  • A 驅動因子名稱,B Base,C Bull,D Bear(皆為藍色輸入值),E 作用中值(黑色公式)。
  • 作用中值透過選擇器擷取。使用 CHOOSE:E5 =CHOOSE(Cover!$B$2,B5,C5,D5)。
  • 等價的 INDEX 寫法:E5 =INDEX(B5:D5,Cover!$B$2)。當案例數量可能增加時,INDEX 較為簡潔;CHOOSE 則在固定三個案例時更易讀。
  • 將選擇的一種公式複製到每個驅動因子行,使該欄公式一致。

連結到模型

  • 每個模型假設儲存格指向作用中值,例如 Model!B6 =ScenarioInputs!E5。
  • 絕不讓模型儲存格內含有情境應控制的直接輸入值;值必須透過選擇器 -> 作用中欄 -> 模型的流程傳遞。
  • 維持連結使用綠色跨頁籤顏色,讓審閱者一看就知道假設是被公式驅動,而非手動輸入。

Outputs 頁籤(並排比較)

同時顯示所有情境,而非僅顯示作用中的情境。兩種穩健的實作方式:

  • 並行計算(較佳,利於稽核):將少數幾個輸出公式複製三份,每個分別餵入 Base、Bull 或 Bear 欄位(而非作用中欄)。例如,Bull 下的 NPV 直接使用 ScenarioInputs!C5:C12 而非 E 欄來重新計算輸出鏈。這樣無需觸碰選擇器即可同時顯示三種結果。
  • 逐一讀取:若模型過大,則記錄比較儲存格是在重新計算步驟中,依序將選擇器設為 1、2、3 後分別捕捉的即時輸出值;需清楚標示哪些儲存格是捕捉的快照,哪些是即時計算的。
  • 佈局:行 = 關鍵指標(營收、EBIT、NPV、IRR),欄 = Base、Bull、Bear,加上 Bull 減 Base 與 Bear 減 Base 的差異欄。

Checks 頁籤

  • 選擇器在範圍內:=AND(Cover!B2>=1,Cover!B2<=3,Cover!B2=INT(Cover!B2)) 結果為 TRUE。
  • 每個驅動因子的三個案例值均已填寫:=COUNTBLANK(ScenarioInputs!B5:D12)=0 結果為 TRUE。
  • 作用中欄與選擇器相符:以一個驅動因子為例,=(ScenarioInputs!E5=CHOOSE(Cover!B2,ScenarioInputs!B5,ScenarioInputs!C5,ScenarioInputs!D5)) 結果為 TRUE。

openpyxl 建置注意事項

  • 使用 openpyxl.worksheet.datavalidation.DataValidation(type="list", formula1='"1,2,3"') 加入下拉選單,接著 ws.add_data_validation(dv) 與 dv.add(ws["B2"])。
  • 所有作用中值與連結儲存格都應寫成公式字串,而非已解析的案例數值;只有在重新計算後才會出現值。
  • 若在下拉選單中使用命名案例,請保留一個隱藏對應表,使選擇器仍能解析為整數供 CHOOSE/INDEX 使用;在同一選擇器中混用文字與索引會破壞公式。
  • 為選擇器儲存格設定明顯的背景色與粗邊框,讓審閱者能立刻識別出這個唯一的控制儲存格。

方向合理性檢查

  • Bull 不應在主要指標上產生比 Base 更差的輸出,Bear 也不應優於 Base;若發生此情況,可能是某個驅動因子的案例值在欄之間被互換了。
  • 建議在 Outputs 頁籤上加入一個非正式的選用檢查,比較每個差異值的正負號是否符合預期方向,以便在重新計算時就能發現欄位互換的問題,而非等到審閱階段。

公式與格式慣例

  • 藍色字體:Base/Bull/Bear 輸入值與選擇器儲存格。
  • 黑色字體:頁籤內的公式(作用中值的 CHOOSE/INDEX 欄、輸出計算)。
  • 綠色字體:跨頁籤連結,例如模型中的 =ScenarioInputs!E5。
  • 不應有公式的地方不寫死數值:作用中欄與模型假設永遠是公式,絕不直接輸入案例值。
  • 每行或每欄使用一致的公式:作用中欄使用相同的 CHOOSE/INDEX 模式;比較欄使用相同的輸出公式。
  • 數字格式:比率為 0.0%,貨幣為 #,##0,倍數為 0.00x。為選擇器儲存格加上填滿色,讓切換位置一目了然。

與內建情況管理員的取捨

Excel 內建的「情況管理員」將案例值儲存在對話方塊中,工作表中不可見,切換時會覆寫即時輸入,且容易與模型不同步。可見的切換區塊將每個案例保持在表格上,使作用中值的擷取成為可追蹤的公式,並讓審閱者無需開啟任何功能表即可同時看到三種結果。這種方式更具可稽核性,且能承受複製、審閱與版本控制。

檢查

請參閱上述 Checks 頁籤:選擇器值在 1..3 範圍且為整數、無空白案例儲存格、作用中值與選擇器對應的案例值相等。以上三項檢查都必須回傳 TRUE。

重新計算與驗證

使用 openpyxl 儲存後,進行無頭重新計算(例如 libreoffice --headless --convert-to xlsx),使 CHOOSE/INDEX 與跨頁籤連結成功解析。重新載入後,掃描 #REF!、#DIV/0!、#VALUE!、#NAME? 等錯誤。將選擇器依序切換至 1、2、3,確認輸出會變化,且作用中值檢查在每個設定下都成立。修正並重複此循環直到完全無誤,然後交付。

需收集的輸入資訊

  • 模型的路徑,以及每個驅動因子的假設儲存格位址。
  • 每個驅動因子的 Base、Bull、Bear 值。
  • 要比較的關鍵輸出指標及其儲存格位址。
  • 比較方式應為並行計算(即時)還是捕捉快照。

範例

假設的驅動因子:營收成長率(Base 4%、Bull 8%、Bear 1%)、毛利率(Base 55%、Bull 58%、Bear 50%)。選擇器 Cover!B2 = 2 選取 Bull,因此 ScenarioInputs!E5 =CHOOSE(2,4%,8%,1%) = 8% 流入 Model!B6。Outputs 頁籤會顯示假設單位的 NPV:Base 為 760、Bull 為 1,140、Bear 為 410,以及 Bull 減 Base 的差異為 380,所有數值同時可見。

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/sensitivity-tables

Builds one- and two-variable sensitivity (Data Table) analysis on a model output in a .xlsx with live formulas and a recalc check, then delivers the workbook. Use when someone wants to see how an output (NPV, IRR, EPS, margin) moves as one or two inputs change. 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.

相關技能