Home Excel Powerpoint Word Outlook Error Codes

VBA Useful Codes

Welcome to the World of VBA
Home > VBAUsefulCodes

Add a worksheet at a specified position using VBA


Excel Macro to add a worksheet at a specified position

Sub addNewSheetInAWorkbookAtPosition()

    Dim wb As Workbook

    Dim fPath As String

 

    fPath = "C:\Users\Desktop\myfile.xlsx"

    Set wb = workbooks.Open(Filename:=fPath)

    ' Add a new worksheet in your workbook

    ' Below statement will add your new sheet at first position

    wb.Worksheets.Add Before:=1

    ' Below statement will add your new sheet at second position

    wb.Worksheets.Add After:=1

    ' Below statement will add your new sheet at the end

    wb.Worksheets.Add After:=Worksheets.Count

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