N
Neil Holden
Below I have code to save as when a macro is pressed.
Can someone tell me firstly, to automatically enter a file name with
reference to whatever is in C4 and to include the date, also to save in a
default location.
Private Sub CommandButton1_Click()
Dim Response As String
Dim msg As String
Dim Style As String
Dim sFilename As String
Dim ans
Dim flToSave As Variant
Dim flName As String
Dim flFormat As Long
msg = "Are you sure you want to Exit the application and Close Excel?"
Style = vbYesNo + vbInformation + vbDefaultButton2
Response = MsgBox(msg, Style)
If Response = vbYes Then
flFormat = ActiveWorkbook.FileFormat
flToSave = Application.GetSaveAsFilename(flName, filefilter:="Excel
Files (*.xls),*.xls", _
Title:="Save File As...")
If flToSave = False Then
Exit Sub
Else
ThisWorkbook.SaveAs Filename:=flToSave, FileFormat:=flFormat
Can someone tell me firstly, to automatically enter a file name with
reference to whatever is in C4 and to include the date, also to save in a
default location.
Private Sub CommandButton1_Click()
Dim Response As String
Dim msg As String
Dim Style As String
Dim sFilename As String
Dim ans
Dim flToSave As Variant
Dim flName As String
Dim flFormat As Long
msg = "Are you sure you want to Exit the application and Close Excel?"
Style = vbYesNo + vbInformation + vbDefaultButton2
Response = MsgBox(msg, Style)
If Response = vbYes Then
flFormat = ActiveWorkbook.FileFormat
flToSave = Application.GetSaveAsFilename(flName, filefilter:="Excel
Files (*.xls),*.xls", _
Title:="Save File As...")
If flToSave = False Then
Exit Sub
Else
ThisWorkbook.SaveAs Filename:=flToSave, FileFormat:=flFormat