Hello, i´ve got this code to save worksheet2 as new excel file. Is it possible to automatically name that exported file from value in choosen cell?
For example if A1="Henry´s list" then file name will be named "Henry´s list". Thanks for answer.
![]()
Sub testRenameSheets() Dim stFileName As String stFileName = Selection.Value Worksheets("Sheet2").Copy 'Creates a new workbook with the sheet. With ActiveSheet.UsedRange .Copy .PasteSpecial xlValues .PasteSpecial xlFormats End With Application.CutCopyMode = False Range("A1").Select stFileLocation = Application.GetSaveAsFilename(InitialFileName:=stFileName) ActiveWorkbook.SaveAs Filename:=stFileLocation & "xlsx" ActiveWorkbook.Close Savechanges:=False End Sub
Bookmarks