VBA/Excel/Access/Word/Excel/Copy Paste

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

Copy and Paste can be carried out entirely by the Copy method

   <source lang="vb">

Sub copy()

    range("A1:B3").copy Destination:=range("G4")

End Sub

</source>
   
  


Copy cells

   <source lang="vb">

Sub CopyHeads()

 With Worksheets("Sheet1").Range("A1")
   .Range(.Cells(1), .End(xlToRight)).Copy _
       Destination:=Worksheets("Sheet2").Range("A1")
 End With

End Sub

</source>
   
  


Overridden with the Destination parameter

   <source lang="vb">

Sub pasteDemo()

    ActiveSheet.Paste Destination:=range("G4")

End Sub

</source>
   
  


Select current range and copy

   <source lang="vb">

Sub SelCurRegCopy()

   Selection.CurrentRegion.Select
   Selection.Copy
   Range("A17").Select " Substitute your range here
   ActiveSheet.Paste
   Application.CutCopyMode = False

End Sub

</source>