VBA for searching a folder and deleting files based on a pre-determined list of file names

xcellrodeo

Board Regular
Joined
Oct 27, 2008
Messages
206
Hi all, I would very much appreciate your help with the following:
Description of problem:
I have 1 tab in my Workbook ('File Names List') which has a list file names and the corresponding path listed. File Names are listed in Col. A starting row 3 and File Path are listed in Col,B also starting row 3.
Please note this file list can change in terms of nr of files to be searched but they will always be either .JPG or .BMP files.
i.e File Name = DSC123.jpg
File Path = C:\Desktop\Test\DSC123.jpg

What I would like to do is write a VBA script which takes this list of file names and checks if these exist in the C:\Desktop\Test folder.
And if they do exist then delete them and if they dont exist then bring up a box which prints the file name which cannot be found.

Hope this makes sense.
thanks alot for your help :)
 
Last edited:

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,214,403
Messages
6,119,308
Members
448,886
Latest member
GBCTeacher

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