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

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi all,

The problem is already solved. You guys can ignore this question.

CJ
 
Upvote 0

Forum statistics

Threads
1,214,863
Messages
6,121,978
Members
449,058
Latest member
oculus

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