Delete file, based on cell name

tm0206

New Member
Joined
Feb 3, 2009
Messages
19
Hi,
I am looking for a VBA to delete a files, with the name of the file coming from a cell value.

Cell A1 = names
I would like to delete the file "names" from c:\inventory\data

I am think of using, but not sure how to include the cell into the statement?
kill c:\inventory\data\"A1".xls
 
Sorry, no... I have been retired and, hence, not had access to a network system, for some 16 years now. I would think if the path is set up correctly, it should work, but I have no way to test that. Does it maybe work if you map your network drive to a local hard disk letter and then use it for the path?
Another question if I need to delete only .pdf files in respective folder how can i write the code? As all files are deleting windows above code.
Thank you
 
Upvote 0

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Hi,
I am looking for a VBA to delete only some files, with the name of the file coming from a cell value. I am using below code but all files are deleting I need to delete only pdf files

Code:
[table="width: 500"]
[tr]
[td]Sub DeleteMultipleFiles()
Shell Environ("comspec") & " /c DEL /Q " & """" & Join(Application.Transpose(Range("A2", Cells(Rows.Count, "A").End(xlUp))), """ """) & """", vbHide
End Sub[/td]
[/tr]
[/table]
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,558
Members
452,928
Latest member
101blockchains

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