View Full Version : Save-As name based on cell value
lpratt
01-09-2022, 08:01 PM
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.
Paul_Hossler
01-10-2022, 04:37 AM
Why not just bring up the folder browser and then save in that folder as A1?
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
No error checking
jolivanes
01-12-2022, 11:03 PM
https://www.excelforum.com/excel-programming-vba-macros/1367991-save-as-name-based-on-cell-value.html
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.