Can someone please help
I am looking for a code that will:
1) Bring up save-as popup
2) Worksheet to be saved as name in cell (A1)
and either
path to be chosen (preferable)
or
to desktop.
Printable View
Can someone please help
I am looking for a code that will:
1) Bring up save-as popup
2) Worksheet to be saved as name in cell (A1)
and either
path to be chosen (preferable)
or
to desktop.
Why not just bring up the folder browser and then save in that folder as A1?
No error checkingCode:Option Explicit
Sub SaveA1()
Dim sFolder As String, sFile As String
With Application.FileDialog(msoFileDialogFolderPicker)
If .Show = -1 Then ' if OK is pressed
sFolder = .SelectedItems(1)
Else
Exit Sub
End If
End With
If Len(sFolder) > 0 Then 'a file was chosen
sFile = sFolder & Application.PathSeparator & ActiveSheet.Range("A1").Value
If UCase(sFile) = UCase(ThisWorkbook.FullName) Then
MsgBox "Can't save with same name as this workbook"
Exit Sub
End If
On Error Resume Next
Application.DisplayAlerts = False
Kill sFile
Application.DisplayAlerts = True
On Error GoTo 0
ThisWorkbook.SaveAs sFile
MsgBox "This workbook saved as " & vbCrLf & vbCrLf & sFile
ThisWorkbook.Close True
End If
End Sub