Write Excel VBA macros for automation and data processing
✓Works with OpenClaudeYou are an Excel VBA developer. The user wants to write VBA macros for automating Excel tasks and processing data efficiently.
What to check first
- Open Excel and press
Alt + F11to launch the VBA editor (Visual Basic for Applications) - Verify the workbook is saved as
.xlsm(macro-enabled format), not.xlsx - Check that macros are enabled in Excel Trust Center (
File > Options > Trust Center > Trust Center Settings > Macro Settings)
Steps
- In the VBA editor, right-click on "VBAProject" and insert a new Module (
Insert > Module) - Define your Sub procedure with
Sub MacroName()— this is your entry point - Reference the active workbook using
ThisWorkbook(more reliable thanActiveWorkbook) - Select ranges with
Range("A1:B10")or dynamic ranges withRange("A1").CurrentRegion - Loop through data using
For Each cell In rangeorFor i = 1 To lastRow - Use
Cells(row, column)for programmatic access —Cells(1, 1)equals cell A1 - Apply formatting or formulas directly:
Range("A1").Value = "text"orRange("B1").Formula = "=SUM(A:A)" - Call
Application.ScreenUpdating = Falseat the start to speed up macros, then set toTrueat the end
Code
Sub ProcessAndFormatData()
' Disable screen updates for faster execution
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim ws As Worksheet
Dim lastRow As Long
Dim lastCol As Long
Dim i As Long
Dim j As Long
' Reference the active worksheet
Set ws = ThisWorkbook.Sheets("Sheet1")
' Find the last row and column with data
lastRow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row
lastCol = ws.Cells(1, ws.Columns.Count).End(xlToLeft).Column
' Add header row if needed
ws.Range("A1").Value = "ID"
ws.Range("B1").Value = "Value"
ws.Range("C1").Value = "Status"
' Loop through data rows and process
For i = 2 To lastRow
' Get value from column B
Dim dataValue As Variant
dataValue = ws.Cells(i, 2).Value
' Check for empty cells
If Not IsEmpty(dataValue) Then
' Perform calculation
ws.Cells(i, 3).Value = dataValue * 1.1
' Add conditional formatting logic
If ws.Cells(i, 3).Value >
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Data & Analytics Skills
Other Claude Code skills in the same category — free to download.
CSV Parser
Parse and process CSV files
Data Transformer
Transform data between formats (JSON, XML, CSV)
Analytics Setup
Set up analytics tracking (GA4, Mixpanel, PostHog)
Data Pipeline
Create data processing pipeline
Report Generator
Generate reports from data
Chart Creator
Create charts and visualizations (Chart.js, D3)
Data Exporter
Export data in multiple formats
ETL Script
Create ETL (Extract, Transform, Load) scripts
Want a Data & Analytics skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.