Move Files To Dynamic Folders Based On Cell Value

wells

New Member
Joined
Jan 9, 2020
Messages
24
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Im not sure this is still possible... I referred few posts but they dont work with current office edition..

I have a folder with say around 100 excel workbooks. I need a macro to

1. Open each file in the directory specified
2. Read the contents of a particular cell, E8
3. Create a folder in the same directory with the value of E8
4. And, move the excel workbook itself to that folder.
5. Then it opens the next file
6. If the value of E8 is the same as that in the first workbook, it simply moves it to the already created folder, else it creates another folder with the new value of E8 and moves it there.


Note: The files are not always saved in a static file path.
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
54,897
Office Version
  1. 365
Platform
  1. Windows
OK, then change this line:
VBA Code:
            newFldr = fldr & Range("E8").Value
to this:
VBA Code:
            newFldr = fldr & Sheets("Order Template").Range("E8").Value
 

Some videos you may like

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

wells

New Member
Joined
Jan 9, 2020
Messages
24
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Joe, words are not enough to thank You..This works perfect... if you would suggest me some areas where I can learn to construct codes like these I will be grateful!!!
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
54,897
Office Version
  1. 365
Platform
  1. Windows
You are welcome.
if you would suggest me some areas where I can learn to construct codes like these I will be grateful!!!
You can pick up a good book on VBA and work through it. There are some good ones in the MrExcel store.
Google searches are a big help too. For instance, I did not know the FileDialog code that I needed. So I did a Google search and found the code that we need for this.
Also, spending time here and reading through interesting threads and trying the code is a good way too. I have been here almost 18 years, and I still am learning new stuff!
 

Watch MrExcel Video

Forum statistics

Threads
1,114,339
Messages
5,547,360
Members
410,789
Latest member
cpolek83
Top