To copy a cell or a range of cells to another worksheet you need to use the VBA’s “Copy” method. In this method, you need to define the range or the cell using the range object that you wish to copy and then define another worksheet along with the range where you want to paste it.
Copy a Cell or Range to Another Worksheet
Range("A1").Copy Worksheets("Sheet2").Range("A1")
- First, define the range or the cell that you want to copy.
- Next, type a dot (.) and select the copy method from the list of properties and methods.
- Here you’ll get an intellisense to define the destination of the cell copied.
- From here, you need to define the worksheet and then the destination range.
Now when you run this code, it will copy cell A1 from the active sheet to the “Sheet2”. There’s one thing that you need to take care that when you copy a cell and paste it to a destination it also pastes the formatting there.
But if you simply want to copy the value from a cell and paste it into the different worksheets, consider the following code.
Worksheets("Sheet2").Range("A1") = Range("A1").Value
This method doesn’t use the copy method but simply adds value to the destination worksheet using an equal sign and using the value property with the source cell.
Copy Cell from a Different Worksheet
Now let’s say you want to copy a cell from a worksheet that is not active at the time. In this case, you need to define the worksheet with the source cell. Just like the following code.
Worksheets("sheet1").Range("A1").Copy Worksheets("Sheet2").Range("A1")
Copy a Range of Cells
Range("A1:A10").Copy Worksheets("Sheet2").Range("A1:A10")
Range("A1:A10").Copy Worksheets("Sheet2").Range("A1")
Copy a Cell to a Worksheet in Another Workbook
When workbooks are open but not saved yet.
Workbooks("Book1").Worksheets("Sheet1").Range("A1").Copy _
Workbooks("Book2").Worksheets("Sheet1").Range("A1")
When workbooks are open and saved.
Workbooks("Book1.xlsx").Worksheets("Sheet1").Range("A1").Copy _
Workbooks("Book2.xlsx").Worksheets("Sheet1").Range("A1")
Copy a Cell to a Worksheet in Another Workbook which is Closed
'to open the workbook that is saved in a folder on your system _
change the path according to the location you have in your _
system
Workbooks.Open "C:\Users\Dell\Desktop\myFile.xlsx"
'copies cell from the book1 workbook and copy and paste _
it to the workbook myFile
Workbooks("Book1").Worksheets("Sheet1").Range("A1").Copy _
Workbooks("myFile").Worksheets("Sheet1").Range("A1")
'close the workbook and after saving
Workbooks("myFile").Close SaveChanges:=True
Related: How to Open a Workbook using VBA in Excel
More on VBA Range and Cells
- How to Set (Get and Change) Cell Value using a VBA Code
- How to Sort a Range using VBA in Excel
- How to Create a Named Range using VBA (Static + Dynamic) in Excel
- How to Merge and Unmerge Cells in Excel using a VBA Code
- How to Check IF a Cell is Empty using VBA in Excel
- VBA ClearContents (from a Cell, Range, or Entire Worksheet)
- Excel VBA Font (Color, Size, Type, and Bold)
- How to AutoFit (Rows, Column, or the Entire Worksheet) using VBA
- How to use OFFSET Property with the Range Object or a Cell in VBA
- VBA Wrap Text (Cell, Range, and Entire Worksheet)
- How to use Range/Cell as a Variable in VBA in Excel
- How to Find Last Rows, Column, and Cell using VBA in Excel
- How to use ActiveCell in VBA in Excel
- How to use Special Cell Method in VBA in Excel
- How to Apply Borders on a Cell using VBA in Excel
- How to Refer to the UsedRange using VBA in Excel
- How to Change Row Height/Column Width using VBA in Excel
- How to Select All the Cells in a Worksheet using a VBA Code
- How to Insert a Row using VBA in Excel
- How to Insert a Column using VBA in Excel