REAL-TIME

VBA Projects

Full Access with Source Code

  • Designed and Developed by PNRao

  • Full Access with VBA Source Code

  • Well Commented Codes Lines

  • Creative and Professional Design

120+ PROFESSIONAL

Project Management Templates

120+ PM Templates Includes:
  • 50+ Excel Templates

  • 50+ PowerPoint Templates

  • 25+ Word Templates

Effortlessly Manage Your Projects

Seamlessly manage your projects with our powerful & multi-purpose templates for project management.

Share Post

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.

Effortlessly Manage Your Projects and Resources
120+ Professional Project Management Templates!

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.

Save Up to 85% LIMITED TIME OFFER
Project Management Templates

All-in-One Pack
120+ Project Management Templates

Essential Pack
50+ PM Templates

Excel Pack
50+ Excel PM Templates

PowerPoint Pack
50+ Excel PM Templates

MS Word Pack
25+ Word PM Templates

Ultimate Project
Management Template
Ultimate Resource
Management Template
Project Portfolio
Management Templates
Categories: VBATags: , , , Last Updated: July 16, 2022

Leave A Comment