AutoSkill 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.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/vba-copy-data-from-xlsx-to-xlsm-in-same-folder" ~/.claude/skills/ecnu-icalk-autoskill-vba-copy-data-from-xlsx-to-xlsm-in-same-folder && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt4_8_GLM4.7/vba-copy-data-from-xlsx-to-xlsm-in-same-folder/SKILL.mdsource content
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
- Dynamic Path: Use
to determine the folder location dynamically.ThisWorkbook.Path - Backslash Enforcement: You MUST ensure the folder path string ends with a backslash (
). Use logic like\
to guarantee this.If Right(folderPath, 1) <> "\" Then folderPath = folderPath & "\" - File Identification: Use
to find the source file name.Dir(folderPath & "*.xlsx") - 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.
- Data Copying: Copy the
from the first sheet (UsedRange
) of the source workbook to cellSheets(1)
(orA1
) of the first sheet of the destination workbook.Cells(1, 1) - Cleanup: Close the source workbook without saving changes (
).SaveChanges:=False - 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