Create a Search Folder button


 

Hi there, ^^ 

 

This tuto will be just a quick presentation of the way by which you can allow the end user to select the source file from which to retrieve source data, through the use of the Windows search window.

 

In order to do so we'll need to create two files : 

 

- The master file where we'll input our macro and copy and paste our inputs 

- The source file containing our source values

 

 

The idea of this little macro, here, being to simply make the search file window pop up to allow the user to select the file that he wants and then copy all the data from this source file into our master file. 

 

So once you created your source file like that : 

 

 

Create your master file and go to into the vba IDE to create a new code module. Here the idea for our macro will be first to call the search file window allowing the user to select a source file and then to save its path in a Variant variable in order to be able to open, copy and close the file before pasting the source values into the sheet1 of our master file. To do so we'll use the following simple code snippet : 

 

 

As you can see here it is the "Application.GetOPenFilename" that allows us to make the search file window pop up whenever the user is running the macro. 

 

And that's it ! You now have a pretty simple but clear example of how you can ask properly the end user to choose a source file through the use of the search file window which in certain cases can come pretty handy to create a proper work around from the basic solution of the dedicated cell in the spreadsheet where we asks the end user to input the whole path of the source file ;)