Hi All,
I need some help with some excel files that I need to organize.
I have a number of excel sheets and a hierarchy of folders and I would like to move these excel sheets into the folders based on keywords in a sentence in cells A1 and B1. An example of these folders is (Finance Department > Headcount > Percentages > 1999). I would like the tool/script to move the folder into that directory if the keywords “Finance Department” AND “Headcount” AND “Percentages” AND “1999” are located in the sentence in cell A1 which would look something like “Headcount numbers across all branches in percentages” and cell B1 would look like "Finance Department 1999"
Is there a macro I could use? Maybe some software that would help?
Let me make sure of your terminology. Do you have a single Excel file that contains multiple worksheets that you want to put in separate files in these directories, or do you have separate excel files with the data in a single worksheet and want the files to be move to the directories? I know what you want to do can be done, but I need to know how your data is setup.
Bob
Click my star if my answer helped you. Mark the thread as [SOLVED] if it has been.
Thanks for replying. I have the latter, separate excel files with the data in single worksheets and I want to move them into directories. That's great! Looking forward to your reply.
This is a bit complicated and I hope you can figure out what is going on. The attached spreadsheet contains a macro. You will need to read the comments in the macro to see what is happening and what you need to do. There are two sheets - one for keywords and one for file paths. Also notice the button on the Keywords sheet that makes the macro run.
MoveFiles.xls
Bob
Click my star if my answer helped you. Mark the thread as [SOLVED] if it has been.
Thank you so much for this. I tried it out and I have a few questions. I would really appreciate it if you would be kind enough to answer them.
1) I tried moving an excel file but I keep getting an error saying that the file (which is apparently the first file in the input folder) does not exist. Does the excel file have to be read only? And what if the text in A1 and B1 is formatted i.e. (Bold, underlined)
2) Do the keywords have to be the exact folder names in the hierarchy? For example, if I had a list of keywords like this "Finance", "Department", "1999", does the corresponding output folder need to have a directory hierarchy with the exact names Finance> Department> 1999?
3) Would a solution similar to the attachment be possible? In the attachment the idea is if a combination of keywords exist then move file into this specific directory. All keywords mentioned must either exist in Cells A1 and B1 in order for the move to happen.
Thank you again for all your help, you are a life saver!
Did you check the path to the input files. It is on the Paths sheet in the original book. The path must have "\" rather than "/" between the subdirectories. The file does not have to be read only. I have opened it read only to prevent updates from occurring during the process. Also, the format of the text on A1 and B1 has no impact on the process. In fact, capitalization has not effect either as the Ucase function is used to do the comparison in upper case.
The way that it is written now requires the subdirectories to appear in the same order as the key words. That can change if desired.
That is an excellent solution to the problem of 2)! Please note that the file will be moved to first directory where all the keyword match, so make sure the list of keywords in unique.
One feature of the original macro is that the first time an excel file in the input directory does not conatin a keyword match, the macro will stop. This is due to a feature of the Dir function. If you need this to continue if a match cannot be found, let me know and we can adjust the macro.
Let me know how you want to proceed.
Bob
Click my star if my answer helped you. Mark the thread as [SOLVED] if it has been.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks