Hi All.
There is a process we do at work which requires to save an excel file to a specific folder (must do it 150 to 200 times each month).
I thought it might be useful to use the command button to save it to that folder and close it rather than going through file/saveas/folder etc etc.
When saving I thought it may be useful to use the text in say Cell "C4" as file name so it appears with that name in the folder if need to look for it.
I tried the bottom two macros but had 2 problems 1) the location it saved in was the master folder in this case "Adhoc" not the subfolder 2) filename wasn't what was in the Cell "C4".
Hope that makes sense
Macro 1)
Private Sub CommandButton1_Click()
Dim path As String
Dim filename As String
path = "C:\Users\R****************\Desktop\Adhoc\Subfolder"
filename = Range("C4").Text
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs filmename11:= path & filename".xlsx", FileFormat:=xlOpenXMLWorkbook
Application.DisplayAlerts = True
ActiveWorkbook.Close
End Sub
Macro 2)
Private Sub CommandButton1_Click()
Dim MyFile As String
MyFile = ActiveWorkbook.Name
'Do not display message about overwriting the existing file.
Application.DisplayAlerts = False
' Save the active workbook with the name of the
' active workbook. Save it on the C drive to a folder called
' "Users" with a subfolder called "R****************\Desktop\Adhoc\Subfolder."
ActiveWorkbook.SaveAs filename:="C:\Users\R****************\Desktop\Adhoc\Subfolder" & MyFile
' Close the workbook by using the following.
ActiveWorkbook.Close
End Sub
Not too sure where I am going wrong (I am very new to VBAs/Macros too).
Any help would be much appriciated.
Thanks in advance
Bookmarks