Skip to content
excel-vba logo

Excel VBA開発スキル

excel-vba

Excel VBA開発の専門スキル。VBAマクロ作成、Excel操作自動化、ワークブック処理時に使用。

SKILL.md

Full skill instructions

Excel VBA開発スキル

基本方針

  • Option Explicit必須
  • エラーハンドリング必須(On Error GoTo)
  • 画面更新・計算の制御でパフォーマンス最適化
  • 変数は明示的に型宣言

標準テンプレート

Sub プロシージャ

Option Explicit

Public Sub ProcessData()
    On Error GoTo ErrorHandler

    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual

    ' 処理本体

CleanUp:
    Application.ScreenUpdating = True
    Application.Calculation = xlCalculationAutomatic
    Exit Sub

ErrorHandler:
    MsgBox "エラー: " & Err.Description, vbExclamation
    Resume CleanUp
End Sub

命名規則

  • モジュール: mod_機能名
  • プロシージャ: 動詞_目的語
  • 変数: キャメルケース(接頭辞付き: str, lng, rng等)

よく使うパターン

最終行取得

Dim lastRow As Long
lastRow = Cells(Rows.Count, 1).End(xlUp).Row

範囲ループ

Dim cell As Range
For Each cell In Range("A1:A" & lastRow)
    ' 処理
Next cell

配列処理(高速)

Dim data As Variant
data = Range("A1:Z1000").Value
' 配列で処理
Range("A1:Z1000").Value = data

パフォーマンス最適化

' 処理開始時
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False

' 処理終了時
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True

エラーハンドリングパターン

On Error GoTo ErrorHandler
' 処理

Exit Sub

ErrorHandler:
    Dim errMsg As String
    errMsg = "エラー番号: " & Err.Number & vbCrLf & _
             "エラー内容: " & Err.Description
    MsgBox errMsg, vbCritical, "エラー"
    ' 必要に応じてログ出力
End Sub

Examples

  • /​excel-vba 売上データを集計したい → ワークシート操作+集計ロジックのテンプレートを提供
  • /​excel-vba 複数のExcelを統合したい → FileSystemObjectとワークブック操作のパターンを提供
  • マクロが遅い → パフォーマンス最適化パターン(ScreenUpdating等)を適用
  • エラーでマクロが止まる → エラーハンドリングテンプレートを提供

Guidelines

  • 必ず Option Explicit を宣言して暗黙の変数宣言を禁止
  • すべてのプロシージャに On Error GoTo ErrorHandler を実装
  • 大量データ処理時は配列に読み込んでからループ処理
  • 処理前後で ScreenUpdating と Calculation を制御
  • 変数名には型を示す接頭辞を付ける(str, lng, rng, ws等)
  • 長いプロシージャは機能ごとに分割して可読性を確保

関連エージェント

  • @excel-vba-expert: VBA開発専門家

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View