Carla R
Carla R

Reputation: 13

Copy multiple ranges of cells in one workbook and paste to two different sheets in another workbook

I have one workbook that I want to copy two different selections and paste into two different sheets in a different workbook.

I want to run this multiple times and want it to paste the selected ranges into subsequent BLANK rows, instead of overwriting a previously pasted row. This is what I have:

    Range("BJ8:EB8").Copy
    Windows("LPI Table 2016.xlsx").Activate
    Sheets("LPI 2.4").Select
    Range("A3").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
         :=False, Transpose:=False
    Windows("NEW LPI-Sheet_011915.xlsm").Activate
    Range("BJ12:EB12").Copy
    Windows("LPI Table 2016.xlsx").Activate
    Sheets("LPI 2.6").Select
    Range("A3").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _

End Sub

Upvotes: 1

Views: 936

Answers (1)

Egan Wolf
Egan Wolf

Reputation: 3573

Instead of

`Range("A3").Select`

use

`Cells(Rows.Count, 1).End(xlUp).Offset(1,0).Select`

Also, try to not use Select statement. It slows down your macro and is usually not necessary. You can rewrite this

Sheets("LPI 2.4").Select
Range("A3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False

and put it all in one line

Sheets("LPI 2.4").Cells(Rows.Count, 1).End(xlUp).Offset(1,0).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
    SkipBlanks:=False, Transpose:=False

Upvotes: 1

Related Questions