Excel VBA: Copy Cell Value and Paste to Another Cell

In this article, I’ll show you how you can copy the value of a cell and paste it to another cell using VBA in Excel. You’ll learn to copy the value of both a single cell and a range of cells using VBA.


Excel VBA: Copy Cell Value and Paste to Another Cell (Quick View)

Sub Copy_Single_Cell_Value()

Copy_Sheet = "Sheet1"
Copy_Cell = "B4"

Paste_Sheet = "Sheet2"
Paste_Cell = "B4"

Worksheets(Copy_Sheet).Range(Copy_Cell).Copy

Worksheets(Paste_Sheet).Range(Paste_Cell).PasteSpecial Paste:=xlPasteAll

End Sub

VBA Code to Copy a Cell Value and Paste to Another Cell


Download Practice Workbook

Download this practice workbook to exercise while you are reading this article.


3 Suitable Methods to Copy Cell Value and Paste to Another Cell Using Excel VBA

Here we’ve got a data set in a worksheet called Sheet1 in an Excel workbook that contains the customer names, contact numbers, and the email addresses of some customers of a bank in the range B3:D13.

Data Set to Copy Cell Value and Paste to Another Cell Using Excel VBA

Our objective today is to copy a cell value and paste it to another cell from this data set using VBA.


1. Copy a Single Cell and Paste It to Another Cell

First of all, we’ll copy the value of a single cell and paste it into another cell. We can paste it into the same worksheet or into a different worksheet.

For example, let’s copy the value of cell B4 (Boris Pasternak) and paste it into cell B4 of Sheet2.

The VBA code will be:

⧭ VBA Code:

Sub Copy_Single_Cell_Value()

Copy_Sheet = "Sheet1"
Copy_Cell = "B4"

Paste_Sheet = "Sheet2"
Paste_Cell = "B4"

Worksheets(Copy_Sheet).Range(Copy_Cell).Copy

Worksheets(Paste_Sheet).Range(Paste_Cell).PasteSpecial Paste:=xlPasteAll

End Sub

VBA Code to Copy a Cell Value and Paste to Another Cell

⧭ Output:

Run this code after changing the inputs. It’ll copy the value from cell B4 of Sheet1 (Boris Pasternak) to cell B4 of Sheet2.


2. Copy an Adjacent Range of Cells and Paste It to Another Range

Next. we’ll copy an adjacent range of cells and paste it to another range.

Let’s copy the range B3:D13 of Sheet1 and paste it into the range B3:D13 of Sheet2.

The VBA code will be:

⧭ VBA Code:

Sub Copy_Adjacent_Range_of_Cells()

Copy_Sheet = "Sheet1"
Copy_Range = "B3:D13"

Paste_Sheet = "Sheet2"
Paste_Range = "B3:D13"

Worksheets(Copy_Sheet).Range(Copy_Range).Copy

Worksheets(Paste_Sheet).Range(Paste_Range).PasteSpecial Paste:=xlPasteAll

End Sub

VBA Code to Copy Cell Value and Paste to Another Cell Using Excel VBA

⧭ Output:

Run this code after changing the inputs. It’ll copy the values from the range B3:D13 of Sheet1 (Boris Pasternak) to the range B3:D13 of Sheet2.

Output to Copy Cell Value and Paste to Another Cell Using Excel VBA


3. Copy a Non-Adjacent Range of Cells and Paste It to Another Range Using Excel VBA

Finally, we’ll copy a non-adjacent range of cells and paste it into another range of cells.

For example, let’s try to copy the range B3:B13 and D3:D13 of Sheet1 to the range B3:C13 of Sheet2.

To join non-adjacent cells of a worksheet into a common range, we’ll use the Union method of VBA.

The VBA code will be:

⧭ VBA Code:

Sub Copy_Non_Adjacent_Range_of_Cells()

Copy_Sheet = "Sheet1"
Copy_Range = Array("B3:B13", "D3:D13")

Paste_Sheet = "Sheet2"
Paste_Range = "B3:C13"

Set Copy_Range2 = Worksheets(Copy_Sheet).Range(Copy_Range(0))

For i = 1 To UBound(Copy_Range)
    Set Copy_Range2 = Union(Copy_Range2, Worksheets(Copy_Sheet).Range(Copy_Range(i)))
Next i

Copy_Range2.Copy

Worksheets(Paste_Sheet).Range(Paste_Range).PasteSpecial Paste:=xlPasteAll

End Sub

⧭ Output:

Change the inputs and run this code. It’ll copy the values from the range B3:B13 and D3:D13 of Sheet1 to the range B3:C13 of Sheet2.


Things to Remember

In this article, we’ve used the xlPasteAll property of the PasteSpecial method of VBA for pasting. Along with it, there are 11 more properties of the PasteSpecial method. You can have a glance at them if you are interested.


Conclusion

Therefore, this is the process to copy a cell value and paste it into another cell using VBA in Excel. Do you have any questions? Feel free to ask us. And don’t forget to visit our site ExcelDemy for more posts and updates.

Rifat Hassan

Rifat Hassan

Hello! Welcome to my profile. Here I will be posting articles related to Microsoft Excel. I am a passionate Electrical Engineer holding a Bachelor’s degree in Electrical and Electronic Engineering from Bangladesh University of Engineering and Technology. Besides academic studies, I always love to keep pace with the revolution in technology that the world is rushing towards day by day. I am diligent, career-oriented, and ready to cherish knowledge throughout my life.

We will be happy to hear your thoughts

Leave a reply

ExcelDemy
Logo