VBA: Pasting rows with an offset

SomeRandomGuy

New Member
Joined
Apr 24, 2019
Messages
2
Hi

I have two sheets that I'm trying to paste between; my source sheet and my target sheet. My VBA is working with the copy / paste however I want to offset the paste so it starts on a specific row.

The source rows start in cell A1 and I want the pasting in the target sheet to start in B5. All of the rows should still be copied. At the moment it copies to B1 in the target sheet.

Code:
_______________



Sub setNames()

Dim nEndRow As Long
Dim a As Long
Dim avail As Worksheet
Dim StartCell As Range

Set avail = Worksheets("Sheet1")

Sheets("workbook_002").Select
Range("A1").Select

nEndRow = Range("a" & Rows.Count).End(xlUp).Row

For a = 1 To nEndRow


nteam = Left(Cells(a, 1).Value, 16)
nname = Mid(Cells(a, 1).Value, 18, 50)

avail.Cells(a, 2) = nname
avail.Cells(a, 3) = nteam

Next a

End Sub
 

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.
Hi there. Replace these 2 lines:
Code:
avail.Cells(a, 2) = nname
avail.Cells(a, 3) = nteam
with
Code:
avail.Cells(a+4, 2) = nname
avail.Cells(a+4, 3) = nteam
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,624
Latest member
gregg777

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top