Hi,
I'm trying to save a hidden sheet as a new file but struggling to get my code working - could somebody possibly help me understand why this is generating an error: 1004
Many thanks
I'm trying to save a hidden sheet as a new file but struggling to get my code working - could somebody possibly help me understand why this is generating an error: 1004
VBA Code:
Sub SaveMyToFile2()
Dim newFName As String
Dim newWSName As String
newFName = Application.GetSaveAsFilename(InitialFileName:=Worksheets("My Data").Range("B3"), filefilter:=" Excel Macro Free Workbook (*.xlsx), *.xlsx,")
newWSName = Right(Worksheets("My Data").Range("B3"), 22)
With Worksheets("My Data")
.Visible = xlSheetVisible
.Range("A1:H41").Select
.Selection.Copy
End With
Workbooks.Add
Application.ActiveSheet.Name = newWSName
Selection.PasteSpecial Paste:=xlPasteAllUsingSourceTheme
Selection.PasteSpecial Paste:=xlPasteColumnWidths
ActiveSheet.Cells.EntireRow.AutoFit
ActiveWorkbook.SaveAs Filename:=newFName, FileFormat:=51, CreateBackup:=False
Worksheets("My Data").Visible = xlSheetHidden
End Sub
Many thanks