Reputation: 91
Good day everyone!
I know how to let user to choose limited number of excel books by userform (textbox + button), but now I'm stuck with such a problem.
I don't know how many files have to be opened (it may be 5 or 50), so the first my thought was to create "refreshing" userform like on sites when you fill one string and then next appears. But it seems too complicated and another thought came: let a user to choose the folder and then open every file and do what I need to do (copy first 2 sheets to initial WB).
My problem is that I have totally no idea how to realize my ideas.
I hope you can help me :) Thanks in advance!
Upvotes: 0
Views: 97
Reputation: 4974
You can do this in multiple ways:
Ask the user to select a folder with the files and not single files (I would go with this option). In this case you can loop through the content of the folder using the DIR function in VBA
Add a textbox for the user to enter the number of files to add, and then do a "for" loop opening the form and asking for each filename and saving the paths to a VBA array or simply opening them in the background
Upvotes: 1