Saving Workbook with VBA assigning Filename from Input On Worksheet

J

Jrew23

Hello, I think this is a relatively easy question. Can someone let me
know what the correct syntax is below? Thanks in advance

Sub MyTest()

Application.ScreenUpdating = False

Dim myFileName As String
Dim myWorksheetName As String
Dim myFolder As String

myFolder = "C:\My Documents\"
myFileName = Range("A1").Value

Debug.Print myFolder

myFileName = myFolder & myFileName & ".xls"
Debug.Print myFileName

'***********************************************************************************************
' problem with my syntax below (see ampersand myfilename ampersand)
' please correct

ActiveWorkbook.SaveAs Filename:="&myfilename&",
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
'**********************************************************************************************

Application.ScreenUpdating = True

End Sub
 
J

JE McGimpsey

Not sure why the &s and quotes - did you try:

ActiveWorkbook.SaveAs Filename:=myFileName, _


??
 
J

Jrew23

That worked. Simple enough! I have to aplogize for taking up your
time! Thanks!!!!
 

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

Similar Threads


Top