ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete all Excel workbooks from a list on worksheet on condition. (https://www.excelbanter.com/excel-programming/443419-delete-all-excel-workbooks-list-worksheet-condition.html)

u473

Delete all Excel workbooks from a list on worksheet on condition.
 
I need monthly to loop and delete all workbooks listed in column A,
(full path and file name is given) where column B content = "Y"
A B
File Delete
C:\Progress\ProjA.xls Y
C:\Progress\ProjB.xls
F:\Perf /ProjA\Elec.xls
F:\Perf /ProjA\Equip.xls Y
Help appreciated

J.P.

Don Guillett Excel MVP

Delete all Excel workbooks from a list on worksheet on condition.
 
On Jul 27, 11:21*am, u473 wrote:
I need monthly to loop and delete all workbooks listed in column A,
*(full path and file name is given) where column B content = "Y"
A * * * * * * * * * * * * * * * * * *B
File * * * * * * * * * * * * * *Delete
C:\Progress\ProjA.xls * * * *Y
C:\Progress\ProjB.xls
F:\Perf /ProjA\Elec.xls
F:\Perf /ProjA\Equip.xls * * Y
Help appreciated

J.P.


Sub killem()
On Error Resume Next
For Each fn In Range("A2:A22")
If UCase(fn.Offset(, 1)) = "Y" Then Kill fn
End If
Next fn
End Sub

u473

Delete all Excel workbooks from a list on worksheet on condition.
 
Brilliant, and thank you again. I was cooking something much more
convoluted.
How would have it been different if path was in Column A, file name in
Column B, Type in Column C and Delete in Column D ?
Sub killem()
On Error Resume Next
For Each fn In Range("A2:A22")
If UCase(fn.Offset(, 4)) = "Y" Then
fn = fn..text + fn.Offset(, 1).text +fn.Offset(, 2).text
Kill fn
End If
Next fn
End Sub
Would t6hat syntax be correct ?
Thank you again,
J.P.


All times are GMT +1. The time now is 05:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com