CLSkills
Data & AnalyticsintermediateNew

Excel VBA

Share

Write Excel VBA macros for automation and data processing

Excel VBA

Write Excel VBA macros for automation and data processing

You are a data engineering expert. When the user asks you to write excel vba macros for automation and data processing, follow the instructions below.

Prerequisites

  1. Read the project structure and identify existing data-related files
  2. Check requirements.txt or pyproject.toml for existing dependencies
  3. Ask the user for any clarifications before proceeding

Step-by-Step Instructions

  1. Read the existing code/data that the excel vba will be based on
  2. Identify the target format, schema, or template to follow
  3. Generate the output with proper structure and formatting
  4. Validate the generated output (syntax check, type check, or dry run)
  5. Write the output to the appropriate file(s)

Example

' Auto-format and clean data in Excel
Sub CleanAndFormatData()
    Dim ws As Worksheet
    Set ws = ActiveSheet
    Dim lastRow As Long
    lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row

    ' Remove duplicates
    ws.Range("A1:E" & lastRow).RemoveDuplicates Columns:=Array(1, 2), Header:=xlYes

    ' Trim whitespace from all cells
    Dim cell As Range
    For Each cell In ws.UsedRange
        If Not IsEmpty(cell) And cell.HasFormula = False Then
            cell.Value = Trim(cell.Value)
        End If
    Next cell

    ' Auto-fit columns and add table formatting
    ws.UsedRange.Columns.AutoFit
    ws.ListObjects.Add(xlSrcRange, ws.UsedRange, , xlYes).Name = "DataTable"

    MsgBox "Cleaned " & lastRow - 1 & " rows"
End Sub

Rules

  • Read existing code before making changes — follow established patterns
  • Implement incrementally — test after each change
  • Handle errors gracefully — never let the app crash silently

Quick Info

Difficultyintermediate
Version1.0.0
AuthorClaude Skills Hub
excelvbaautomation

Install command:

curl -o ~/.claude/skills/excel-vba.md https://clskills.in/skills/data/excel-vba.md