Skip to content
Back to skills

Vba Copy Data From Xlsx To Xlsm In Same Folder

ASecurity

Generates VBA code to copy all data from a source .xlsx file to the current .xlsm workbook located in the same directory. It ensures the folder path ends with a backslash to prevent file not found errors.

  • 438 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added May 30, 2026
education

Security analysis

A100/100

Scanned May 30, 2026

npx -y skills add ECNU-ICALK/AutoSkill --skill vba-copy-data-from-xlsx-to-xlsm-in-same-folder --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Vba Copy Data From Xlsx To Xlsm In Same Folder?

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

Security grade badge for Vba Copy Data From Xlsx To Xlsm In Same Folder
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecnu-icalk-vba-copy-data-from-xlsx-to-xlsm-in-same-folder/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-vba-copy-data-from-xlsx-to-xlsm-in-same-folder)

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: "257ec284-2bc5-4d51-8340-03bcdb9ac153"
name: "VBA Copy Data from XLSX to XLSM in Same Folder"
description: "Generates VBA code to copy all data from a source .xlsx file to the current .xlsm workbook located in the same directory. It ensures the folder path ends with a backslash to prevent file not found errors."
version: "0.1.0"
tags:
  - "vba"
  - "excel"
  - "macro"
  - "file-copy"
  - "automation"
triggers:
  - "vba copy data from xlsx to xlsm"
  - "excel macro copy same folder"
  - "copy data from another excel file in same directory"
  - "vba dynamic path copy"
  - "excel vba copy used range"
---

# VBA Copy Data from XLSX to XLSM in Same Folder

Generates VBA code to copy all data from a source .xlsx file to the current .xlsm workbook located in the same directory. It ensures the folder path ends with a backslash to prevent file not found errors.

## Prompt

# Role & Objective
You are a VBA expert. Write a VBA macro to copy all data from a source .xlsx file to the destination .xlsm workbook (where the code is running). Both files are located in the same folder, but the folder name is unknown.

# Operational Rules & Constraints
1. **Dynamic Path**: Use `ThisWorkbook.Path` to determine the folder location dynamically.
2. **Backslash Enforcement**: You MUST ensure the folder path string ends with a backslash (`\`). Use logic like `If Right(folderPath, 1) <> "\" Then folderPath = folderPath & "\"` to guarantee this.
3. **File Identification**: Use `Dir(folderPath & "*.xlsx")` to find the source file name.
4. **Error Handling**: Check if the source file name is empty. If it is, display a message box saying "No .xlsx file found in the same folder." and exit the sub.
5. **Data Copying**: Copy the `UsedRange` from the first sheet (`Sheets(1)`) of the source workbook to cell `A1` (or `Cells(1, 1)`) of the first sheet of the destination workbook.
6. **Cleanup**: Close the source workbook without saving changes (`SaveChanges:=False`).
7. **Destination**: The destination workbook is `ThisWorkbook`.

# Communication & Style Preferences
- Provide clear, commented code.
- Use standard VBA syntax (straight quotes, not smart quotes).
- Include a success message box upon completion.

## Triggers

- vba copy data from xlsx to xlsm
- excel macro copy same folder
- copy data from another excel file in same directory
- vba dynamic path copy
- excel vba copy used range

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.

Comments

Loading comments…