# how to copy multiple cells from various rows

#### Falcons88

##### New Member
Hi,

I am trying to copy multiple cells from one sheet and paste them into another, I have code to copy them from a single line which is:

Sheets("Input Sheet").Range("A6:H6").Copy

but I am trying to copy and paste the below highlighted range in a specific order as numbered in the highlighted cells (H18 is the last one to be copied)

they are being pasted into the following table called "invoices", the sheet is also called invoices.

### Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a \$25,000 loan, 5% annual interest, 60 month loan.

#### DanteAmor

##### Well-known Member
Try this:

VBA Code:
``````Sub copycells()
Dim i As Long, j As Long
Dim ar1 As Variant, ar2 As Variant

ar1 = Array("B7", "D7", "E7", "A7", "C7", "H18")
ar2 = Array(1, 2, 3, 4, 5, 7)
With Sheets("invoices").ListObjects("invoices")
i = .DataBodyRange.Rows.Count
For j = 0 To UBound(ar1)
.DataBodyRange(i, ar2(j)).Value = Sheets("Input Sheet").Range(ar1(j)).Value
Next
End With
End Sub``````

#### Falcons88

##### New Member
Try this:

VBA Code:
``````Sub copycells()
Dim i As Long, j As Long
Dim ar1 As Variant, ar2 As Variant

ar1 = Array("B7", "D7", "E7", "A7", "C7", "H18")
ar2 = Array(1, 2, 3, 4, 5, 7)
With Sheets("invoices").ListObjects("invoices")
i = .DataBodyRange.Rows.Count
For j = 0 To UBound(ar1)
.DataBodyRange(i, ar2(j)).Value = Sheets("Input Sheet").Range(ar1(j)).Value
Next
End With
End Sub``````
Thank you so much @DanteAmor

Replies
2
Views
193
Replies
1
Views
170
Replies
3
Views
216
Replies
4
Views
98
Replies
11
Views
175

1,141,816
Messages
5,708,751
Members
421,588
Latest member
Wawie

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back