Changing the ActiveCell

B

Bruce A. Julseth

I want to Select and copy several block of data based on where the initial
ActiveCell is locate. The following copys the first block.

Dim StartingCell As String
Dim EndingCell As String
Dim RowOffset As Integer
Dim ColOffset As Integer

RowOffset = 2
ColOffset = 3

StartingCell = ActiveCell.Address
EndingCell = ActiveCell.Offset(RowOffset, ColOffset).Address

Worksheets("Sheet1").Range(StartingCell & ":" & EndingCell).Copy _
Destination:=Worksheets("Sheet2").Range("Jeff")

Now, "Logically" I want to Add RowOffset and ColOffset to StartingCell and
to EndingCell and repeat the above copy:

Worksheets("Sheet1").Range(StartingCell & ":" & EndingCell).Copy _
Destination:=Worksheets("Sheet2").Range("Tom")

How do I do the addition to change the values for Starting and Ending Cells?

Thanks....

Bruce
 
J

JE McGimpsey

One way:


Assuming that the activecell is on Sheet1 (and assuming you only want to
move down the active sheet, not across by adding colOffset):

With ActiveCell
.Resize(3, 4).Copy Sheets("Sheet2").Range("Jeff")
.Offset(3,0).Resize(3, 4).Copy Sheets("Sheet2").Range("Tom")
End With

or

With ActiveCell.Resize(3, 4)
.Copy Sheets("Sheet2").Range("Jeff")
.Offset(3,0).Copy Sheets("Sheet2").Range("Tom")
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top