Dear @Detlef,
Thank you for posting your question in the Microsoft Q&A forum.
I truly appreciate your patience, and I’m sorry I can’t fully test or build a custom macro for you right now. Therefore, I highly recommend you publishing on Stack Overflow (English only). You can post VBA programming questions to Stack Overflow by using the vba tag, along with any other relevant tags.
Please note that Stack Overflow has guidelines such as requiring a descriptive title, a complete and concise problem statement, and sufficient details to reproduce your issue. Feature requests or overly broad questions are considered off topic.
Disclaimer: Microsoft provides no assurances and/or warranties, implied or otherwise, and is not responsible for the information you receive from the third-party linked sites or any support related to technology.
Even so, I want to set you up for success with clear guidance and trusted references that other users have confirmed work.
Option 1: Listing sub‑directories & files into Excel using VBA
VBA script for looping through folders + subfolders and writing results into Excel. For reference: How to write a script listing sub-dir & files then put the list into Excel ?
Option 2: Prompt the user to select a folder and return the path as a string
VBA code where a dialog box would appear for the user to select where they want to save the files. For reference: https://stackoverflow.com/questions/26392482/vba-excel-to-prompt-user-response-to-select-folder-and-return-the-path-as-string
Disclaimer: Microsoft provides no assurances and/or warranties, implied or otherwise, and is not responsible for the information you receive from the third-party linked sites or any support related to technology.
Since most “copy directory into Excel” macros rely on FSO, these references are essential when you need to understand how folder and file operations work in VBA. The FileSystemObject (FSO) documentation covers all the core methods you’ll use in your macro, including:
- .GetFolder: retrieve a folder object you can iterate through
- .Files and .SubFolders: loop through all files and nested directories
- .GetExtensionName: identify file types
- .CopyFolder and .CopyFile: perform actual file or directory copy operations
- You can find the full official documentation here: FileSystemObject object
Please understand that as forum moderator, my primary goal is to provide helpful guidance and support through general steps/information. While I don’t have access to internal systems or test devices required to resolve issues, I truly appreciate your understanding of these limitations. I genuinely hope the information I share helps guide you in the right direction, and I'm always here to assist as much as I can within my scope.
I hope the above information can help you and I'll leave that question open in case one of our amazing volunteers has ideas for you. Feel free to send a message if you need further help.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.