VBA to copy worksheet into new workbook and then save, close and return to original
Hi,
I am looking at a macro that copies one worksheet (values and formats) from Workbook A into a new workbook (Workbook B). The sheet in question contains a cell (FO9) that I would like the new file name to be called.
I currently have the copy and paste function working ok, and all data has copied over correctly to the new workbook.
What I’m after is for the new workbook to “save as” automatically as an XLSM file using the name in cell FO9 in workbook B. The user must however be asked where to save it (save as). I then need this workbook to close and for the user to return back to cell AO64 in Workbook A, with Sheet 1 being hidden again, and for Sheet 2 to then become the active worksheet again.
The code I currently have is:
Sub SaveAsA0()Application.ScreenUpdating = FalseRange("D3").SelectSheets("Sheet 1").Visible = TrueSheets("Sheet 2").Visible = TrueSheets("Sheet 1").SelectActiveSheet.Copy With ActiveSheet.UsedRange .Copy .PasteSpecial xlValues .PasteSpecial xlFormats End With Application.CutCopyMode = FalseEnd Sub