Reputation: 325
I'm unable to solve this problem. When I am copying my range, it will only copy 2 rows
I can pause the code and check the variables are what I begin with below. The issue is when i Copy, i only have Rows 4 and 5 of data. I can pause the code after Copy and Paste manually. Still 2 rows. If i hard code the references into the Set rTriggerBody - it works.
I'm confused why a reference would be any different from hard coding the number?
badbExport and newWorkbook are different Workbooks.
Thank you - code below
Dim baDbExport As Worksheet
Dim rTriggerBody As Range
Set baDbExport = ActiveWorkbook.ActiveSheet
Set rTriggerBody = baDbExport.Range(Cells(iRecordRowBegin, iTriggerColBegin), Cells(iRecordRowEnd, iTriggerColEnd))
iRecordRowBegin = 4
iRecordRowEnd = 14
iTriggerColBegin = 10
iTriggerColEnd = 48
With newWorkbook
Set wsTrigger = ActiveSheet
wsTrigger.Name = "Trigger Dates"
Set rExportTriggerDatesBody = wsTrigger.Range("A3")
rTriggerBody.Copy
rExportTriggerDatesBody.PasteSpecial xlPasteAll
End With
Upvotes: 0
Views: 44
Reputation: 35915
You are setting rTriggerBody in row 4.The values for the variables at that time is not clear from your snippet.
You do not change the rTriggerBody range again, even after you change the variables that you used to define the range, so when you copy rTriggerBody, it is still covering what is defined in row 4 of the code.
Looks like you want to move the command that sets the range to after you have actually changed the variables that are used to define the range.
iRecordRowBegin = 4
iRecordRowEnd = 14
iTriggerColBegin = 10
iTriggerColEnd = 48
Set rTriggerBody = baDbExport.Range(Cells(iRecordRowBegin, iTriggerColBegin), Cells(iRecordRowEnd, iTriggerColEnd))
Upvotes: 1