Excel VBA: Move filenames listed in Column to Folder path in Contents of cell

waxsublime

New Member
Joined
Jul 13, 2013
Messages
17
Hi folks!

I was wondering if anyone happen to know or have a macro that can move files


BadGood
C:\Example\BadC:\Example\Good
alvinsimon
axiomverisimilitude
austindallas

<tbody>
</tbody>

Row 1 = Title
Row 2 = Target Folder Path
Rows 3+ = file name to be moved to target folder in Row 1 of column

Each of these files listed are *.log files. The filename should be an exact match to name of file, but excluding the ".log". (For example, if "alvin" is listed in col A, the file "alvin.log" will be moved to folder: C:\Example\Bad).

I'm wanting to have three columns, sorting these files into three different target folders named in row 2.

It seems like an operation that might be useful in a wide variety of scenarios, but I couldn't find anything quite fitting this in my searches. Thanks in advance for any help.
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Thanks for the kind reply!

Yes, I looked through those threads before I posted here, but like I said, they aren't quite doing what I'm looking for. Namely, a conditional move based on file name lists.
 
Upvote 0
it's a matter of using the move code, with an if statement surrounding it.

if file.name = X

or even if you have a field that has a list of names you want to copy.
if application.worksheetfunction.countif(range of name,file.name)>0 then
move the file.
else nothing

So long as you're using the right code to move the file, the if function will then determine which files go and which don't
 
Upvote 0

Forum statistics

Threads
1,215,233
Messages
6,123,772
Members
449,123
Latest member
StorageQueen24

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top