Delete all files when date arrives

gicimi

New Member
Joined
Mar 14, 2019
Messages
12
Hello,


files with the extension on the specified date need automatic deletion.

[FONT=&quot].csv.pdf.xla.xlam.xls.xls.xlsb.xlsm.xlsx[/FONT][FONT=&quot]

[/FONT]
can you help me?
****** id="cke_pastebin" style="position: absolute; top: 72px; width: 1px; height: 1px; overflow: hidden; left: -1000px;">can you help me</body>
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
6,977
Office Version
  1. 365
Platform
  1. Windows
Welcome to the forum - your explanation is very short - is this what you want ?

:eek::eek: You cannot undo this - so be very careful :eek::eek:

If the date today is after 25 August delete all files in folder C:\Folder\SubFolder with extensions .csv .pdf .xla .xlam .xls .xls .xlsb .xlsm .xlsx

Code:
Sub DeleteFiles()
    Dim Ext As Variant
    If Date [COLOR=#006400]>[/COLOR] CDate("[COLOR=#006400]25 August 2019[/COLOR]") Then
        For Each Ext In Split("[COLOR=#0000cd].csv .pdf .xla .xlam .xls .xls .xlsb .xlsm .xlsx[/COLOR]")
            On Error Resume Next
            Kill "[COLOR=#ff0000]C:\Folder\SubFolder\*[/COLOR]" & Ext
            On Error GoTo 0
        Next
    End If
End Sub
 
Last edited:

James006

Well-known Member
Joined
Apr 4, 2009
Messages
3,680
Hello,

It is not such much their extensions ... but their respective locations you will have to monitor in order to run your macro ...:wink:
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
59,901
Office Version
  1. 365
Platform
  1. Windows
@gicimi
Please do not post the same question multiple times. All clarifications, follow-ups, and bumps should be posted back to the original thread.
Per forum rules, posts of a duplicate nature will be locked or deleted (rule 12 here: Forum Rules).

I have merged both your threads
 

Forum statistics

Threads
1,136,288
Messages
5,674,867
Members
419,530
Latest member
undisclosed

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
Top