How to Copy & Paste in Excel VBA

Written by jaime avelar
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Copy & Paste in Excel VBA
Save time by using Excel VBA's copy and paste functions. (Jupiterimages/Brand X Pictures/Getty Images)

Copying and pasting data from one cell to another is a common task in Microsoft Office Excel. Getting this task done using Visual Basic for Applications, or VBA, can save you a lot of time if you have to copy and paste in many spreadsheets, because VBA allows you to write sub procedures that you can execute to perform a task such as copy and paste. Use VBA's Selection.Copy method to copy data in a particular cell and paste it in another using the Paste method.

Skill level:
Moderately Easy

Other People Are Reading

Instructions

  1. 1

    Launch Excel and type "copy this data" in cell A1. Click the "Developer" tab and click "Visual Basic." Insert a new module by clicking the "Insert" menu and "Module."

  2. 2

    Start a new sub procedure in Visual Basic Editor by typing the following VBA code:

    Private Sub copyAndPaste()

  3. 3

    Continue by adding the following VBA code to copy A1 data to D1:

    Range("A1").Select
    
    Selection.Copy
    
    Range("D1").Select
    
    ActiveSheet.Paste
    
  4. 4

    Type "End Sub" to end the sub procedure.

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the eHow.co.uk site, you consent to the use of cookies. For more information, please see our Cookie policy.