Move worksheet in VBA is used to move the worksheet(s) from one location to another location in the same workbook or another new workbook or existing workbook. Here Move is method of worksheet object. Sometimes we may want to move worksheet in the active workbook at the beginning of the worksheet or in between worksheets or at the end of worksheet. Need basis we can move the worksheets using Move worksheet method in VBA.

In this Topic:

VBA Move Worksheet

VBA Move Worksheet: Syntax

Please find the below syntax to Move Worksheet at the beginning of the Worksheet or In-between Worksheet’s or end of the Worksheet using VBA.

Worksheets(“Worksheet Name”).Move([Before], [After])

Where
Before: It’s an Optional parameter. The worksheet will be moved to before the specified worksheet. Then we can’t specify after parameter.
After: It’s an Optional parameter. The worksheet will be moved to after the specified worksheet. Then we can’t specify after parameter.

Note: If we don’t specify Optional parameter either Before or After, Excel will create new workbook and it contains moved Worksheet.

VBA Move Worksheet: Using Before

Please find the below , It will show you how to Move the Worksheet to the beginning.

Sub MoveSheet_Beginning()
    Worksheets("Sheet3").Move Before:=Worksheets(1)
End Sub

In the above we are moving the Worksheet named ‘Sheet3’ to the beginning of the worksheet. Where ‘1’ represents the Worksheet index number (Nothing but first available sheet in the workbook).

Sub MoveSheet_Beginning1()
    ActiveSheet.Move Before:=Worksheets(1)
End Sub

In the above we are moving the active worksheet to the beginning of the worksheet.

VBA Move Worksheet: Using After

Please find the below , It will show you how to Move the Worksheet at the end of the available worksheets.

Sub MoveSheet_End()
    Worksheets("Sheet3").Move After:=Worksheets(Worksheets.Count)
End Sub

In the above we are moving the Worksheet named ‘Sheet3’ to the end of the worksheet. Where ‘Worksheets.Count’ represents the number of available worksheets in the workbook

Sub MoveSheet_End()
    ActiveSheet.Move After:=Worksheets(Worksheets.Count)
End Sub

In the above we are moving the active worksheet to the end of the worksheet.

VBA Move Worksheet: Before Specified Worksheet

Please find the below example , It will show you how to Move the Worksheet either before or after the specified worksheet.

Sub MoveSheet_Before()
    Worksheets("Sheet2").Move Before:=Sheets("Sheet5")
End Sub

Please find the above , we are moving ‘Sheet2’ to the before ‘Sheet5’.

Sub MoveSheet_Before()
    ActiveSheet.Move Before:=Sheets("Sheet5")
End Sub

In the above , we are moving active sheet to the before ‘Sheet5’.

Sub MoveSheet_After()
    Worksheets("Sheet2").Move After:=Sheets("Sheet5")
End Sub

Please find the above , we are moving ‘Sheet2’ to the after ‘Sheet5’.

Sub MoveSheet_After()
    ActiveSheet.Move After:=Sheets("Sheet5")
End Sub

In the above , we are moving active sheet to the after ‘Sheet5’.

VBA Move Worksheet: To New Workbook

Please find the below , It will show you how to Move the Worksheet named ‘Sheet1’ to new workbook.

Sub MoveSheet_NewWorkbook()
    Sheets("Sheet1").Move
End Sub

Please find the below , It will move the active worksheet to new workbook.

Sub MoveSheet_NewWorkbook()
    ActiveSheet.Move
End Sub

VBA Move Worksheet: To Specific Workbook

Please find the below , It will show you how to Move the Worksheet named ‘Sheet1’ to Specific workbook before ‘Sheet3’.

Sub MoveSheet_SpecificWorkbook ()
    Sheets("Sheet1").Move Before:=Workbooks("YourWorkbookName.xls").Sheets(“Sheet3”)
End Sub

Please find the below , It will move the active worksheet to Specific workbook after ‘Sheet3’.

Sub MoveSheet_SpecificWorkbook ()
    ActiveSheet.Move After:=Workbooks("YourWorkbookName.xls"). Sheets(“Sheet3”)
End Sub

VBA Move Worksheet: Instructions

Please follow the below step by step instructions to execute the above mentioned VBA macros or codes:
Step 1: Open an Excel Worksheet
Step 2: Press Alt+F11 to Open VBA Editor
Step 3: Insert a Module from Insert Menu
Step 4: Copy the above code for activating a range and Paste in the code window (VBA Editor)
Step 5: Save the file as macro enabled Worksheet
Step 6: Press ‘F5′ to run it or Keep Pressing ‘F8′ to debug the code line by line and have a look how the Worksheet(s) moving in the workbook.

120+ Professional Project Management Templates!
Save Up to 85% LIMITED TIME OFFER

A Powerful & Multi-purpose Templates for project management. Now seamlessly manage your projects, tasks, meetings, presentations, teams, customers, stakeholders and time. This page describes all the amazing new features and options that come with our premium templates.

Browse All Templates
Excel VBA Project Management Templates

All-in-One Pack
120+ Project Management
Premium Templates
View Details

Essential Pack
50+ Project Management
Premium Templates
View Details
50+ Excel
Project Management
Templates Pack
View Details
50+ PowerPoint
Project Management
Templates Pack
View Details
25+ MS Word
Project Management
Templates Pack
View Details
Ultimate Project Management Template
View Details
Ultimate Resource Management Template
View Details
Project Portfolio Management Templates
View Details
By Last Updated: July 16, 2022Categories: VBATags: , , ,

Share This Story, Choose Your Platform!

Leave A Comment