Saving as variable file name

L

leerem

I have the following code but it doesn't work as it should, can anyone advise
where I'm going wrong.

Dim Filename
Workbooks.Add
Filename = "Report Week 1.xls"
' Name Workbook
ActiveWorkbook.SaveAs Filename:="D:\Store Returns\Reports\Filename", _
FileFormat:=xlNormal, CreateBackup:=False

Application.DisplayAlerts = False

This will save the file with the name of "Filename" how can I change this
code to reflect the variable name - Filename

Regards

Lee
 
S

Stefi

strFilename = "Report Week 1"
ActiveWorkbook.SaveAs Filename:="D:\Store Returns\Reports\" & strFilename, _
FileFormat:=xlNormal, CreateBackup:=False

Not tested, but better to avoid using Excel keywords as variable names!

Regards,
Stefi

„leerem†ezt írta:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top