VBA Worksheet Method:-
Activate
Copy
Delete
Move
Protect
Select
UnProtect
---------------------------------------------------------------------------------
VBA Activate Worksheet
Sub Activate_Sheet()
Worksheets("Project1").Activate
'Or
Sheets("Project1").Activate
End Sub
---------------------------------------------------------------------------------
Example-2
Sub Activate_Sheet_BasedOnIndex()
Worksheets(1).Activate
'Or
Sheets(1).Activate
End Sub
----------------------------------------------------------------------------
VBA Copy Worksheet Method –Before: Example 1
Sub CopySheet_Beginning()
Worksheets("Sheet3").Copy Before:=Worksheets(1)
End Sub
---------------------------------------------------------------------------------
Sub CopySheet_Beginning1()
ActiveSheet.Copy Before:=Worksheets(1)
End Sub
----------------------------------------------------------------------------------
Sub CopySheet_End()
Worksheets("Sheet3").Copy After:=Worksheets(Worksheets.Count)
End Sub
----------------------------------------------------------------------------------------
Sub CopySheet_End()
ActiveSheet.Copy After:=Worksheets(Worksheets.Count)
End Sub
-----------------------------------------------------------------------------------
VBA Delete Worksheet Method: Example
Sub Delete_Sheet()
Sheets("Sheet2").Delete
‘Or
Sheet2.Delete
End Sub
--------------------------------------------------------------------------------------
Sub Delete_ActiveSheet()
ActiveSheet.Delete
End Sub
--------------------------------------------------------------------------------------
Sub Delete_Sheet_WithoutWarningMessage()
Application.DisplayAlerts = False
Sheets("Sheet2").Delete
Application.DisplayAlerts = True
End Sub
-----------------------------------------------------------------------------------
VBA Move Worksheet Method: Before
Sub MoveSheet_Beginning()
Worksheets("Sheet3").Move Before:=Worksheets(1)
End Sub
------------------------------------------------------------------------------------
Sub MoveSheet_Beginning1()
ActiveSheet.Move Before:=Worksheets(1)
End Sub
--------------------------------------------------------------------------------
Sub MoveSheet_End()
Worksheets("Sheet3").Move After:=Worksheets(Worksheets.Count)
End Sub
------------------------------------------------------------------------
Sub MoveSheet_End()
ActiveSheet.Move After:=Worksheets(Worksheets.Count)
End Sub
----------------------------------------------------------------------
VBA Protect Worksheet Method – Without Password
Sub Protect_WorkSheet_Without_Password()
Sheets("Sheet1").Protect
End Sub
-----------------------------------------------------------------------
VBA Protect Worksheet Method – With Password
Sub Protect_WorkSheet_With_Password()
Sheets("Sheet1").Protect "YourPassword", True, True
End Sub
-----------------------------------------------------------------------
VBA Select Worksheet Method
Sub Select_Range()
Worksheets("Project1").Activate
Range("A1").Select
End Sub
----------------------------------------------------------------------
VBA Select Worksheet Method: Example 2
Sub Select_Range()
Worksheets(1).Activate
Range("A1").Select
End Sub
------------------------------------------------------------------------
VBA UnProtect Worksheet Method –
Sub Unprotect_WorkSheet_Without_Password()
Sheets("Sheet1").Unprotect
End Sub
------------------------------------------------------------------------
Sub Unprotect_WorkSheet_With_Password()
Sheets("Sheet1").Unprotect "YourPassword"
End Sub