SaveAs with WeekNum to update the file name everyweek

iwilli

New Member
Joined
Jan 31, 2012
Messages
43
I download data from home office every week. I make a few edits and then need to save it a few times with different names for different uses later. My question this go around: Is it possible to have it save with the week number automatically updating each week? I thought this would work but I get an error as Excel cannot find the file. What am I doing wrong this time?

Code:
    Dim lrow As Long
    wk = Format(DateTime.Now, "ww")
    ActiveWorkbook.SaveAs Filename:= _
        "C:\Users\iwilli\Documents\Region\CWA Region\Condensed_Weekly_Advisor_Results_by_Market_Group_or_Region-Week" & wk & "xlsx" _
        , FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
try defining wk like this:
Code:
wk = WorksheetFunction.WeekNum(Date, 1) 'Use 1 if week begins on Sunday, 2 for Monday
 
Upvote 0
-- removed inline image ---

Thanks JoeMo but I get the same Run-time error.

Run-time error '1004':
Microsoft Excel cannot access the file
'C:\User\iwilli\Documents\Region\CWA Results\38FED340'

Any other ideas?
 
Upvote 0
-- removed inline image ---

Thanks JoeMo but I get the same Run-time error.

Run-time error '1004':
Microsoft Excel cannot access the file
'C:\User\iwilli\Documents\Region\CWA Results\38FED340'

Any other ideas?
Looks like you are missing a path separator. Maybe:
Code:
filename:= "C:\User\iwilli\Documents\Region\CWA Results\38FED340" & Application.PathSeparator & wk &".xlsx"
 
Upvote 0
Looks like you are missing a path separator. Maybe:
Code:
filename:= "C:\User\iwilli\Documents\Region\CWA Results\38FED340" & Application.PathSeparator & wk &".xlsx"

I changed the code and I get the same run-time error. thanks for the ideas though. I am just completely lost.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,327
Members
452,635
Latest member
laura12345

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