VBA/Excel/Access/Word/Excel/Worksheet Move

Материал из VB Эксперт
Перейти к: навигация, поиск

copy the third worksheet before the 2nd worksheet

 
Sub SimpleWorksheetMovement() 
    " copy the third worksheet before the 2nd worksheet 
    ThisWorkbook.Worksheets(3).Copy ThisWorkbook.Worksheets(2) 
End Sub



copy the third worksheet to a new book

 
Sub SimpleWorksheetMovement() 
    ThisWorkbook.Worksheets(3).Copy 
End Sub



Drag the third worksheet to the first sheet position

 
Sub Macro3()
    Sheets("Sheet3").Select
    Sheets("Sheet3").Move Before:=Sheets(1)
End Sub



Move sheet to the end

 
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