Forum Discussion
Matching file names in Excel column to file names in folder
Subodh_Tiwari_sktneer Thank you for your reply. Where would I enter this code? And can I undo this after I'm done with the task?
You should place this code on a Standard Module like Module1 and to do so follow these steps...
- Open your file and then press Alt+F11 to open VB Editor.
- On VB Editor Ribbon -->go to Insert Tab --> and choose Module. This will insert a new Module called Module1 and open a code window.
- Paste the code into the opened code window, close the VB Editor.
- Save your file as Macro-Enabled Workbook.
- On the sheet with data, insert a Shape or a Button from Form Controls, right click to it and choose Assign Macro and then choose the macro SearchFiles from the available macro list and click OK to finish.
- Now you may click this shape or button to run the code.
Please find the attached in which I have placed the code on Module1 and inserted a button called "Search Files" on the Sheet. You may click this button to run the code.
No, you cannot undo the steps performed by the macro. Btw what is there which you want to undo after the code execution?
In the attached, I have also tweaked the path of the source folder. Now the code assumes that you have a folder called "Document folder" with all the files on your Desktop.
The tweaked line is as below...
rootFolder = Environ("UserProfile") & "\Desktop\Document Folder"
- eledder_Aug 25, 2021Copper ContributorHello, everyone. I've been trying to use this macros with no luck. I've already modify path to a folder located in my desktop, names my worksheet after the name, changed colour number but Im only able to creat a folder inside the destination folder. What could possibly is going wrong?
- TheBorgMay 25, 2021Copper Contributor
Subodh_Tiwari_sktneer How can i modify the code from your example file that can i search just a part of the filename not the exact filename?
If in the search folder i have the file named 111;222;333.pdf if i search 222 the result should be exactly like i search the entire filename.
- Ozz_KozzOct 16, 2020Copper Contributor
Subodh_Tiwari_sktneer Thank you for your detailed response! I will give that a try and circle back if I run into any errors.