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.From its SKILL.md
npx -y skills add ECNU-ICALK/AutoSkill --skill vba-copy-data-from-xlsx-to-xlsm-in-same-folderAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
SKILL.md
2.3 KB, 431 tokens by cl100k_base, as published. Nobody here has run it
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
ThisWorkbook.Pathto determine the folder location dynamically. - Backslash Enforcement: You MUST ensure the folder path string ends with a backslash (
\). Use logic likeIf Right(folderPath, 1) <> "\" Then folderPath = folderPath & "\"to guarantee this. - File Identification: Use
Dir(folderPath & "*.xlsx")to find the source file name. - 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
UsedRangefrom the first sheet (Sheets(1)) of the source workbook to cellA1(orCells(1, 1)) of the first sheet of the destination workbook. - 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
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.