VBA/Excel/Access/Word/Excel/Worksheet Move
Содержание
copy the third worksheet before the 2nd worksheet
<source lang="vb">
Sub SimpleWorksheetMovement()
" copy the third worksheet before the 2nd worksheet ThisWorkbook.Worksheets(3).Copy ThisWorkbook.Worksheets(2)
End Sub
</source>
copy the third worksheet to a new book
<source lang="vb">
Sub SimpleWorksheetMovement()
ThisWorkbook.Worksheets(3).Copy
End Sub
</source>
Drag the third worksheet to the first sheet position
<source lang="vb">
Sub Macro3()
Sheets("Sheet3").Select Sheets("Sheet3").Move Before:=Sheets(1)
End Sub
</source>
Move sheet to the end
<source lang="vb">
Sub Move_Sheet()
Dim myWorksheet As Worksheet Dim myWorksheetName As String myWorksheetName = "MyName" Sheets.Add.Name = myWorksheetName Sheets(myWorksheetName).Move After:=Sheets(Sheets.Count) Sheets("Sheet1").Range("A1:A5").Copy _ Sheets(myWorksheetName).Range("A1")
End Sub
</source>