Hi all
Currently I am working on pasting data from a workbook into another one.
Hope you guys understands what i'm trying to do here. I'll try to explain. I have break my excel workbook using page break into several pages, and as you can see above, I'm trying to put only 15 data into 1st page, and then wish to start the 16th data on another page by offset it by 2, causing the data to be pasted on the 2nd page. Now maybe you can see what's wrong with my code, when my a is 17, it will continue on the first page. Need some help to tweak on this. Please help...
Thanks in advance,
CJ
Currently I am working on pasting data from a workbook into another one.
Code:
Dim a As Integer
For a = 1 To numOfFiles
Dim sheetsName As String
Windows("Report Generator.xls").Activate
Sheets(a).Select
sheetsName = ActiveSheet.Name
Range("B3:B5000").Select
Selection.Copy
Windows("Template.xls").Activate
Sheets("S11").Select
Range("B10").Select
If (a = 16 Or a = 31) Then
ActiveCell.Offset(0, a + 2).Select
ActiveCell = sheetsName
Range("B11").Select
ActiveCell.Offset(0, a + 2).Select
ActiveSheet.Paste
Else
ActiveCell.Offset(0, a - 1).Select
ActiveCell = sheetsName
Range("B11").Select
ActiveCell.Offset(0, a - 1).Select
ActiveSheet.Paste
End If
Next
Hope you guys understands what i'm trying to do here. I'll try to explain. I have break my excel workbook using page break into several pages, and as you can see above, I'm trying to put only 15 data into 1st page, and then wish to start the 16th data on another page by offset it by 2, causing the data to be pasted on the 2nd page. Now maybe you can see what's wrong with my code, when my a is 17, it will continue on the first page. Need some help to tweak on this. Please help...
Thanks in advance,
CJ