Morning all.
I have written my first little bit of code totally on me todd and got it to work kind of.
Basically I have an excel file called template whcih I copied to a new folder. Opened said file and ran my code which enters date into cell B2 then saves the files as e.g. Week Ending 25 October 2019.xlsx It then advances count by 1 and WE date by 7 days and repeats 'x' number of times.
I have a couple of questions neither of which s a big issue, but I was always a kid that asked WHY
My 1st question being it saves not into the original file location not the folder I copied the template to before funning the code, is there something stored in file properties somewhere that causes this.
My 2nd question is it prompts me to save as xlsx as it has code in and I just click yes to save without. I tried defining the file as .xlsx but it wouldn't compile.
My code
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]Sub CreateFiles()
Dim WE As Date
WE = "25/10/2019"
Dim count As Long
count = 0
Do While count < 5
Range("B2").Value = WE
ActiveWorkbook.SaveAs Filename:="Week Ending" & Format(WE, " dd mmmm yyyy")
WE = (WE + 7)
count = (count + 1)
Loop
End Sub
[/FONT]
Thanks in advance
I have written my first little bit of code totally on me todd and got it to work kind of.
Basically I have an excel file called template whcih I copied to a new folder. Opened said file and ran my code which enters date into cell B2 then saves the files as e.g. Week Ending 25 October 2019.xlsx It then advances count by 1 and WE date by 7 days and repeats 'x' number of times.
I have a couple of questions neither of which s a big issue, but I was always a kid that asked WHY
My 1st question being it saves not into the original file location not the folder I copied the template to before funning the code, is there something stored in file properties somewhere that causes this.
My 2nd question is it prompts me to save as xlsx as it has code in and I just click yes to save without. I tried defining the file as .xlsx but it wouldn't compile.
My code
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]Sub CreateFiles()
Dim WE As Date
WE = "25/10/2019"
Dim count As Long
count = 0
Do While count < 5
Range("B2").Value = WE
ActiveWorkbook.SaveAs Filename:="Week Ending" & Format(WE, " dd mmmm yyyy")
WE = (WE + 7)
count = (count + 1)
Loop
End Sub
[/FONT]
Thanks in advance