Copy paste values to another sheet VBA

Copy paste in VBA is similar to what we do in the Excel worksheet:

  1. We can copy a value and paste it to another cell.
  2. We can use Paste Special to paste only the values. Similarly, in VBA, we use the copy method with range property to copy a value from one cell to another.
  3. We use the worksheet function Paste Special or the paste method to paste the value.

How to Copy Paste in VBA?

Below are some examples of how to copy-paste in Excel using VBA.

The basic thing we do in Excel is copy, cut, and paste the data from one cell to another. It requires no special introduction as well. However, learning VBA coding is important to understand the same concept in coding language. Copy paste in VBA is the routine task we do daily in Excel. To copy first, we need to decide which cell to copy.

Copy paste values to another sheet VBA

You are free to use this image on your website, templates, etc, Please provide us with an attribution linkArticle Link to be Hyperlinked
For eg:
Source: Copy Paste in VBA (wallstreetmojo.com)

Example #1 – Copy and Paste Values Using Range Object

Assume you have the word “Excel VBA” in cell A1.

Copy paste values to another sheet VBA

For example, if you want to copy cell A1, we can use the VBA RANGE objectRange is a property in VBA that helps specify a particular cell, a range of cells, a row, a column, or a three-dimensional range. In the context of the Excel worksheet, the VBA range object includes a single cell or multiple cells spread across various rows and columns.read more.

Code:

Sub Copy_Example()

  Range ("A1").

End Sub
Copy paste values to another sheet VBA

We can see all its properties and methods when you reference the cellCell reference in excel is referring the other cells to a cell to use its values or properties. For instance, if we have data in cell A2 and want to use that in cell A1, use =A2 in cell A1, and this will copy the A2 value in A1.read more. So, select the method “Copy.”

Code:

Sub Copy_Example()

  Range("A1").Copy

End Sub

After selecting the method, press the “Spacebar” key to see the argument of the copy method.

Copy paste values to another sheet VBA

It shows “Destination.”

It is nothing, but where do you want to copy-paste values in VBA without selecting the PASTE method.

If we are pasting in the same sheet, we can select the cell using the Range object. For example, let us say if we want to paste the value in the B3 cell, we can put the destination as “Range(“B3″).”

Code:

Sub Copy_Example()

  Range("A1").Copy Destination:=Range("B3")

End Sub

It will copy the data from cell A1 and paste it into cell B3.

We can also use the below method to paste the data.

Code:

Sub Copy_Example()
  
  Range("A1").Copy
  Range("B3").Select
  ActiveSheet.Paste

End Sub

First, we will copy and select the data from cell A1 and paste it into cell B3.

Example #2 – Copy to another Worksheet in the Same Workbook

Suppose we want to copy-paste the value from the different worksheets using VBA macro, then in the Destination argument. In that case, we need to reference the sheet name using the WORKSHEETS object and then mention the range of cells in that WORKSHEET. The below code will do the job.

Code:

Sub Copy_Example()

  Range("A1").Copy Destination:=Worksheets("Sheet2").Range("B3")

End Sub

If we want to copy the data from a specific sheet and paste it into another separate sheet, we need to mention both the names of the sheets.

Firstly, we need to mention the copying sheet.

Worksheets("Sheet1").Range("A1").Copy

Then, in the “Destination argument,” we need to mention the targeted worksheet name and range of the cell.

Destination:=Worksheets("Sheet2").Range("B3")

So, the code should be like this.

Code:

Sub Copy_Example()

  Worksheets("Sheet1").Range("A1").Copy Destination:=Worksheets("Sheet2").Range("B3")

End Sub

Example #3 – Copy from One Workbook to another Workbook

We have seen how to copy from one worksheet to another worksheet in the same workbook. But, we can also do this from one workbook to another workbook.

Take a look at the below code.

Code:

SubCopy_Example()

  Workbooks("Book 1.xlsx").Worksheets("Sheet1").Range("A1").Copy
  Workbooks("Book 2.xlsx").Activate

  ActiveWorkbook.Worksheets("Sheet 2").Select
  ActiveSheet.Paste

End Sub

Firstly, it will copy the data from the worksheet “Sheet1” in the workbook “Book1.xlsx” from cell A1.

Workbooks("Book 1.xlsx").Worksheets("Sheet1").Range("A1").Copy”

Then it will activate the workbook “Book 2.xlsx”.

Workbooks("Book 2.xlsx").Activate

The active workbook will select the worksheet “Sheet 2.”

ActiveWorkbook.Worksheets("Sheet 2").Select

Now in the active sheet, it will paste.

ActiveSheet.Paste

Alternative Way for using Copy-Paste in VBA

We have one more alternative way of having the data from one cell to another cell. Assume you have the word “Excel VBA” in cell A1 and you need the same to come in cell B3.

Copy paste values to another sheet VBA

One method we have seen is using the VBA copy and paste method. Now, we will show you one of the alternative ways. Look at the below piece of code to understand.

Code:

Sub Copy_Example1()

  Range("A1").Value = Range("B3").Value

End Sub

The above says whatever the value is there in cell A1 should be equal to the value in cell B3.

Range("A1").Value = Range("B3").Value

Even though this is not a copy and paste method still adds more value to our coding knowledge.

Top Ways of VBA Copy and Paste as Values

Now, we will see different ways of VBA copy and paste values. Assume you are in cell A1 as shown in the below image.

Copy paste values to another sheet VBA
  • If we want to copy and paste, we need to reference the cell here. Rather, we can use the property of the Selection.Copy method.

Code:

Sub Copy_Example1()

  Selection.Copy Destination:=Range("B3")

End Sub

OR

Sub Copy_Example1()

  ActiveCell.Copy Destination:=Range("B3")

End Sub
  • If you want to copy the entire used range of the worksheet, you can use the below code.

Code:

Sub Copy_Example2()

  Worksheets("Sheet1").UsedRange.Copy Destination:=Worksheets("Sheet2").Range("A1")

End Sub

It will copy the entire used range in the worksheet “Sheet1” and paste it into the worksheet “Sheet2.”

This article has been a guide to VBA Copy Paste. Here, we discuss the top ways to copy and paste in VBA, examples, and a downloadable Excel template. Below are some useful Excel articles related to VBA: –

  • Copy Formatting in Excel
  • Excel VBA Paste Values
  • Excel VBA File Copy Function
  • Excel VBA Paste

How do I copy and paste from one sheet to another in Excel VBA?

Copy Data from one Worksheet to Another in Excel VBA – An Example.
Open an excel workbook..
Enter some data in Sheet1 at A1:B10..
Press Alt+F11 to open VBA Editor..
Insert a Module for Insert Menu..
Copy the above code and Paste in the code window..
Save the file as macro enabled workbook..
Press F5 to run it..

How do I copy and paste values in Excel VBA?

How to Paste Values in Excel using VBA?.
Step 1: Copy the cell B6. To copy the cell B6, use the code as Range (“B6”).Copy..
Step 2: Select the destination cell. In this case, C6 cell. ... .
Step 3: Run the Code. Run this code we will get the B6 copy in C6. ... .
Step 4: Perform a Paste Special Method. ... .
Step 5: Run the Code..

How do I copy and paste VBA code?

We use Dot (.) operator to use the copy and paste methods in VBA. We can copy an entire column and paste it to another column and similarly we can also copy an entire row and paste it to another row.

How do I copy a cell value from one sheet to another?

1. Right-click the cell you want to copy (cell A1 on Sheet1), and click Copy (or use the keyboard shortcut CTRL + C). 2. Go to (1) the second sheet (Sheet2), (2) and Right-click the cell where you want to paste (A1), and (3) choose Paste (or use the keyboard shortcut CTRL + V).