When this skill is activated, always start your first response with the 🧢 emoji.
Spreadsheet Modeling
Spreadsheet modeling is the discipline of building structured, auditable, and maintainable workbooks in Microsoft Excel or Google Sheets. A well-built model separates inputs from calculations from outputs, uses named ranges for clarity, and avoids hardcoded values buried in formulas. This skill equips an agent to write advanced formulas, design pivot tables and dashboards, author VBA macros and Apps Script automations, and architect workbooks that scale from quick analyses to enterprise financial models.
When to use this skill
Trigger this skill when the user:
- Needs help writing or debugging a spreadsheet formula (XLOOKUP, INDEX-MATCH, SUMIFS, array formulas, etc.)
- Wants to build or modify a pivot table or pivot chart
- Asks to create a dashboard with charts, KPIs, or conditional formatting
- Needs a VBA macro or Google Apps Script to automate a spreadsheet task
- Wants to build a financial model, forecast, or what-if scenario analysis
- Asks about data validation rules, drop-downs, or input constraints
- Needs to clean, transform, or restructure data within a spreadsheet
- Wants to optimize a slow workbook or audit an existing model for errors
Do NOT trigger this skill for:
- Database queries or SQL - use a database skill instead
- Python/R data analysis (pandas, NumPy) - use a data-engineering skill instead
Key principles
-
Separate inputs, calculations, and outputs - Every model should have a clear flow: assumptions/inputs on one sheet, calculations on another, and summary/output on a third. Never mix hardcoded inputs into formula cells.
-
One formula per row/column pattern - A column of formulas should use the same formula copied down. If row 5 has a different formula than row 6 in the same column, the model is fragile and hard to audit.
-
Name things - Use named ranges and structured table references instead of raw cell addresses.
=Revenue * Tax_Rateis auditable;=B7*$K$2is not. -
No magic numbers - Every literal value in a formula should either be a named constant or live in a clearly labeled input cell. If you see
*1.08in a formula, extractTax_Rateas a named input. -
Design for the next person - Use consistent formatting, color-code input cells (typically blue font on yellow background), and add cell comments for non-obvious logic. Models outlive their creators.
Core concepts
Workbook architecture organizes a model into layers. The standard pattern is: Inputs/Assumptions sheet (all editable parameters), Calculations sheet (pure formulas referencing inputs), and Output/Dashboard sheet (charts, KPIs, summary tables). Larger models add a Cover/TOC sheet and a Data sheet for raw imports.
Structured tables (Excel Tables / named ranges in Sheets) are the foundation
of maintainable formulas. A table auto-expands when data is added, supports
structured references like =SUM(Sales[Revenue]), and makes pivot tables
reliable. Always convert raw data ranges to tables before building on them.
Array formulas and dynamic arrays enable powerful multi-cell calculations. Excel's FILTER, SORT, UNIQUE, and SEQUENCE functions (and their Google Sheets equivalents) replace many complex INDEX-MATCH or helper-column patterns with single formulas that spill results across multiple cells.
Pivot tables summarize large datasets without formulas. They support grouping, calculated fields, slicers for interactivity, and can feed charts. The key skill is choosing the right row/column/value/filter field layout for the question being asked.
Common tasks
Write a lookup formula
Use XLOOKUP (Excel 365+) or INDEX-MATCH as the universal lookup pattern. Avoid VLOOKUP for new work - it breaks when columns are inserted.
XLOOKUP (Excel 365+ / Google Sheets):
=XLOOKUP(lookup_value, lookup_array, return_array, "Not found", 0)
INDEX-MATCH (all versions):
=INDEX(return_range, MATCH(lookup_value, lookup_range, 0))
Two-criteria lookup (INDEX-MATCH-MATCH):
=INDEX(data_range, MATCH(row_value, row_headers, 0), MATCH(col_value, col_headers, 0))
Always wrap lookups in IFERROR or use XLOOKUP's built-in if_not_found argument to handle missing values gracefully.
Build a conditional aggregation
Use SUMIFS/COUNTIFS/AVERAGEIFS for multi-criteria aggregation.
=SUMIFS(Sales[Amount], Sales[Region], "West", Sales[Date], ">="&DATE(2025,1,1))
Dynamic array alternative (Excel 365+):
=SUM(FILTER(Sales[Amount], (Sales[Region]="West") * (Sales[Date]>=DATE(2025,1,1))))
SUMIFS criteria ranges must all be the same size. Mismatched ranges produce a #VALUE! error with no helpful message.
Create a pivot table
Step-by-step framework for designing a pivot table:
- Define the question - "What is total revenue by region and product category for Q1?"
- Identify the fields - Rows: Region, Product Category. Values: SUM of Revenue. Filter: Date (Q1)
- Build the pivot - Select data table, Insert > PivotTable, drag fields to areas
- Format - Apply number formatting to values, add a slicer for Date for interactivity
- Refresh strategy - If source data changes, right-click > Refresh. For auto-refresh, use VBA or Apps Script
Calculated field example (add a margin calculation inside the pivot):
Margin = Revenue - Cost
Pivot tables silently exclude rows with blank values in row/column fields. Clean your data before pivoting.
Design a dashboard
Build dashboards on a dedicated output sheet that references calculation sheets.
Layout checklist:
- Top row: Title, date range selector (data validation drop-down), refresh button
- Row 2-4: KPI cards (large numbers) - Revenue, Growth %, Units Sold
- Main area: 2-3 charts (combo chart for trends, bar chart for comparisons, pie only if fewer than 6 categories)
- Bottom or right: Detail table with conditional formatting (data bars, color scales)
KPI formula pattern:
=TEXT(total_revenue, "$#,##0") & " (" & TEXT(growth_rate, "+0.0%;-0.0%") & ")"
Conditional formatting rules for a heatmap:
- Select the data range
- Apply Color Scale: Green (high) to Red (low) for positive metrics
- Apply Data Bars for volume metrics
- Use Icon Sets (arrows) for period-over-period change columns
Write a VBA macro (Excel)
Use VBA for repetitive tasks, custom functions, or workbook automation.
Basic macro structure:
Sub FormatReport()
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Data")
Dim lastRow As Long
lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
ws.Range("A1:Z1").Font.Bold = True
ws.UsedRange.Columns.AutoFit
ws.Range("D2:D" & lastRow).NumberFormat = "$#,##0.00"
MsgBox "Report formatted: " & lastRow - 1 & " rows processed."
End Sub
Custom function (UDF):
Function WeightedAverage(values As Range, weights As Range) As Double
Dim i As Long
Dim sumProduct As Double
Dim sumWeights As Double
For i = 1 To values.Cells.Count
sumProduct = sumProduct + values.Cells(i).Value * weights.Cells(i).Value
sumWeights = sumWeights + weights.Cells(i).Value
Next i
If sumWeights = 0 Then
WeightedAverage = 0
Else
WeightedAverage = sumProduct / sumWeights
End If
End Function
VBA macros must be saved in .xlsm format. UDFs are volatile by default in some contexts - avoid calling volatile functions inside them.
Write a Google Apps Script
Use Apps Script for automation in Google Sheets (email alerts, data imports, scheduled tasks).
function sendWeeklyReport() {
const ss = SpreadsheetApp.getActiveSpreadsheet();
const dashboard = ss.getSheetByName("Dashboard");
const revenue = dashboard.getRange("B2").getValue();
const growth = dashboard.getRange("B3").getValue