Offset Ideas Help

YCJ

New Member
Joined
Feb 28, 2011
Messages
29
Hi all

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
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,224,616
Messages
6,179,908
Members
452,949
Latest member
beartooth91

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