Home Excel Powerpoint Word Outlook Error Codes

VBA Useful Codes

Welcome to the World of VBA
Home > VBAUsefulCodes

Copy Sheet to New workbook


Copy entire sheet to new workbook & save the workbook as the sheet name

Function saveasnewwb(wsname)

    Dim wbnew As Workbook

    Set wbnew = Workbooks.Add

    ThisWorkbook.Sheets(wsname).Copy Before:=wbnew.Sheets(1)

    Application.DisplayAlerts = False

    wbnew.Sheets("Sheet1").Delete

    wbnew.SaveAs ThisWorkbook.Path & "\" & wsname & ".xlsx"

    wbnew.Close True

    Application.DisplayAlerts = True

End Function

Sub save_as_new_workbook()
	Call saveasnewwb("Sheet1")
End sub

Subscribe

Enter your e-mail below and get notified on the latest blog posts.




Tags

VBA Outlook KPI Excel Alt+F11 Dashboards Macros Recording Graphs Automation Developer WaterFall Powerpoint Charts Pivot Tables Forecast Charts


Follow Us