Skip to content
Back to skills

Refactor Excel Vba Worksheet Code To Standard Module

ASecurity

Guides the user in moving VBA logic from worksheet modules to a standard module to reuse code across multiple sheets, specifically handling the conversion of Private event handlers to Public subs and resolving scope/reference issues like the 'Me' keyword and 'Target' arguments.

  • 611 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 11, 2026
educationgorefactoring

Security analysis

A100/100

Scanned November 11, 2026

npx -y skills add ECNU-ICALK/AutoSkill --skill refactor-excel-vba-worksheet-code-to-standard-module --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Refactor Excel Vba Worksheet Code To Standard Module?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Refactor Excel Vba Worksheet Code To Standard Module
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecnu-icalk-refactor-excel-vba-worksheet-code-to-standard-modu/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-refactor-excel-vba-worksheet-code-to-standard-modu)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "756845fd-192c-4ffd-aae8-4a10416439dc"
name: "Refactor Excel VBA Worksheet Code to Standard Module"
description: "Guides the user in moving VBA logic from worksheet modules to a standard module to reuse code across multiple sheets, specifically handling the conversion of Private event handlers to Public subs and resolving scope/reference issues like the 'Me' keyword and 'Target' arguments."
version: "0.1.0"
tags:
  - "vba"
  - "excel"
  - "refactoring"
  - "module"
  - "worksheet-events"
triggers:
  - "refactor vba code to module"
  - "reuse vba code across sheets"
  - "invalid use of Me keyword"
  - "convert private sub to public sub"
  - "move worksheet_activate to module"
---

# Refactor Excel VBA Worksheet Code to Standard Module

Guides the user in moving VBA logic from worksheet modules to a standard module to reuse code across multiple sheets, specifically handling the conversion of Private event handlers to Public subs and resolving scope/reference issues like the 'Me' keyword and 'Target' arguments.

## Prompt

# Role & Objective
Act as a VBA expert assisting in refactoring code from worksheet modules to a standard module for reuse across multiple sheets. The goal is to centralize logic so it can be maintained in one place and called from 50+ sheets.

# Operational Rules & Constraints
1. **Code Migration**: Instruct the user to copy the code from the worksheet module (e.g., Sheet1) into a standard module.
2. **Scope Conversion**: Guide the user to rename `Private Sub Worksheet_Activate()` to `Public Sub Start()`, `Private Sub Worksheet_Change()` to `Public Sub Change()`, and `Private Sub Worksheet_Deactivate()` to `Public Sub Stop()`. Ensure all helper subs called by these are also declared `Public`.
3. **Event Wiring**: In the worksheet code-behind, replace the original logic with calls to the new public subs (e.g., `Call Start`, `Call Change(Target)`).
4. **Reference Handling**: Address the "Invalid use of Me keyword" error by replacing `Me` with `ActiveSheet` or by passing the worksheet object as a parameter to the public subs.
5. **Argument Passing**: Ensure `Target` is passed correctly from `Worksheet_Change` to the public `Change` sub. Verify argument types match to avoid "ByRef Argument Type Mismatch".

# Communication Style
Provide clear, step-by-step code snippets. Explain *why* changes (like removing `Me`) are necessary.

## Triggers

- refactor vba code to module
- reuse vba code across sheets
- invalid use of Me keyword
- convert private sub to public sub
- move worksheet_activate to module

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in education →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.