Move Method of Worksheet Object VBA

Move worksheet method in VBA is used to move the worksheet from one location to another location in the same workbook or another new workbook or existing workbook.

PREMIUM TEMPLATES LIMITED TIME OFFER

ON SALE80% OFF

50+ Project Management Templates Pack
Excel PowerPoint Word

Advanced Project Plan & Portfolio Template
Excel Template

Business Presentations Templates Pack
PowerPoint Slides

20+ Excel Project Management Pack
Excel Templates

20+ PowerPoint Project Management Pack
PowerPoint Templates

10+ MS Word Project Management Pack
Word Templates


Why we use Move Worksheet Method in VBA?

If we want to move worksheet from one workbook to another existing workbook or new workbook we will use Move 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.

VBA Move Worksheet Method: Syntax

Here is the syntax to Move Worksheet using VBA.

Sheets(“Worksheet Number”).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 you don’t specify either before or after, Excel will create new workbook that contains the moved worksheet.

VBA Move Worksheet Method: Before

Please find the below example, 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 example 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 example we are moving the active worksheet to the beginning of the worksheet.

VBA Move Worksheet Method: After

Please find the below example, 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 example 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 example we are moving the active worksheet to the end of the worksheet.

VBA Move Worksheet Method: Instructions

Please follow the below step by step instructions to execute the above mentioned VBA macros or codes:

  1. Open an Excel Worksheet
  2. Press Alt+F11 :This will Open the VBA Editor. Otherwise, you can open it from the Developer Tab
  3. Insert a Module from Insert Menu
  4. Copy the above code for activating worksheet and Paste in the code window(VBA Editor)
  5. Save the file as macro enabled Worksheet
  6. Press ‘F5’ to run it or Keep Pressing ‘F8’ to debug the code line by line and check how the Worksheet is Moving.
LIMITED TIME OFFER

Leave A Comment


Related pages


excel vba set cell colorcopy excel workbook to another workbookexcel filter based on cell valuedays360 excel formulaunhide multiple rows in excelvba clearoffset function in exceltracking sheet excel templateexcel vba chooseexcel mergervba query tablevba remove duplicateshow to delete rows and columns in excelexcel vba torrentdelete range vbaexcel listbox vbasample vb programs with source codeunderstanding excel formulasdelete a row vbaddl and dml commands in sqlexcel identify duplicate valuesfree excel dashboard widgetsexcel dashboard ideasexcel color index chartexcel find duplicates in a listbuilding excel dashboardscreateobject vbaexcel 2010 project plan templateworkbook save vbaexcel vba booleanmultiple project dashboard template excelvba dim as rangeremove duplicates in arraysumif in vbaexcel macro enabled workbookvba function leftadvanced charting in excelformat excel vbadashboard excel tutorialexcel password remover macrobar chart schedule in excelinsert comment excelcheck mark for excelisna function vlookupcount if formulasql pivot table examplessort command exceldelete all blank rows in excelddl and dml commands in sql pdfexcel vba programmingexcel import data from another worksheetdelete duplicate cells in excelisna formula in excelweekly plan template excelexcel vba range resizeexcel macro clear sheetexcel developer tutorialexcel vba create new workbookadvanced filter in excel 2010vba macros for beginnersexcel vba refreshvba macromacros not working in excel 2013trend analysis template excelhow to open an excel file in vbatrim formula in excel 2007vba statementsconcatenate formula excelhow protect excel sheet with passwordinsert in excel formulasample pivot tablesexcel vba active workbookexcel unprotect macroif statements excelhow to run a sql query in excelautofilter excel 2007excel formulas for average