Help using variable in KILL command file path

PatrickSchmidt

New Member
Joined
Apr 30, 2014
Messages
25
Hello,
I made a macro to save a file with todays date in a folder. I'll be doing this everyday and I don't want the folder to fill with workbooks. I would like to keep yesterdays and delete the file dated the day before yesterday.
Also If anyone can give me a tip for adding in holidays to the workday function I'd really appreciate it.
Any help is greatly appreciated. Thank you!
Excel 2010
my variables and code that are not working:

Sub CleanUp()


Dim TwoDays
TwoDays = Format(WorksheetFunction.<wbr>WorkDay(Date, -2), "yyyy mm-dd")

Kill "C:\Test\ & TwoDays & TheRestOfFileName.xlsx"


End Sub
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
you are going to need to create a list of holidays depeing on the relevant Country, excel only understands weekends, the optional argument (holidays) needs to be a list given by the user
 
Upvote 0
And for the first question try:

Rich (BB code):
Dim TwoDays as String

Rich (BB code):
Kill "C:\Test\" & TwoDays & "TheRestOfFileName.xlsx"

 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

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