Copying Data from One Range to Another range is most commonly performed task in Excel VBA programming. We can copy the data, Formats, Formulas or only data from particular range in Excel Workbook to another range or Sheet or Workbook.
This example to show you how to copy data from one Range to another using Excel VBA. This is one of the frequently used codes in the VBA, we often do this activity, copying the data from one range to another range in a worksheet.r
Copy Data from One Range to Another in Excel VBA- Solution(s):
You can use Copy method of a range to copy the data from one range to another range.
Copy Data from One Range to Another in Excel VBA – An Example
The following example will show you copying the data from one range to another range in a worksheet using Excel VBA.
'In this example I am Copying the Data from Range ("A1:B10") to Range(E1") Sub sbCopyRange() 'Method 1 Range("A1:B10").Copy Destination:=Range("E1") 'Here the first part is source range, 'and the second part is target range or destination. 'Target can be either one cell or same size of the source range. 'Method 2 Range("A1:B10").Copy Range("E1").Select ActiveSheet.Paste 'In the second method, first we copy the source data range 'Then we select the destination range 'Target can be either one cell or same size of the source range. 'Then we paste in the active sheet, so that it will paste from active range Application.CutCopyMode = False End Sub
- 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
Now you should see the required data (from Range A1 to B10 ) is copied to the target range (Range E1 to F10).