Hi,
I was wondering if someone can point me in the right direction with the following code please?
The background for the code is to loop through the next 180 days, and if the date is not a Saturday or Sunday then it will open the template and save it under the respective date. However, I get a mismatch error in the IF statement.
I can get it to work if I do
etc.
But I want a 'smarter' code if possible
This is the code I've wrote which is not working
Thanks
I was wondering if someone can point me in the right direction with the following code please?
The background for the code is to loop through the next 180 days, and if the date is not a Saturday or Sunday then it will open the template and save it under the respective date. However, I get a mismatch error in the IF statement.
I can get it to work if I do
Code:
IF zdate = "Monday" then
....
etc.
But I want a 'smarter' code if possible
This is the code I've wrote which is not working
Code:
Dim zdate, savedate As String, i As Long
For i = 1 To 180[INDENT] zdate = Format(Date + i, "DDDD")[/INDENT]
[INDENT] savedate = Format(Date + i, "DD.MM.YYYY") & ".xls"[/INDENT]
[INDENT=2] If zdate Is Not "Saturday" Or "Sunday" Then[/INDENT]
[INDENT=2] Workbooks.Open Filename:=ActiveWorkbook.Path & "\Template.xls"[/INDENT]
[INDENT=2] ActiveWorkbook.SaveAs Filename:=savedate, _[/INDENT]
[INDENT=2] accessMode:=xlShared[/INDENT]
[INDENT=2] Windows(savedate).Close[/INDENT]
[INDENT=2] Windows("MacroRunner.xls").Activate[/INDENT]
[INDENT=2] End If[/INDENT]
Next i
Thanks