ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   copy-paste error (https://www.excelbanter.com/excel-programming/296455-re-copy-paste-error.html)

Bernie Deitrick

copy-paste error
 
Ryan,

Try changing your Activate to a Select:

Worksheets("Sheet1").Cells(Rows.Count, 1).End(xlUp) _
.Offset(1, 0).Activate

to

Worksheets("Sheet1").Cells(Rows.Count, 1).End(xlUp) _
.Offset(1, 0).Select

Activate doesn't modify the current selection if the cell being activated is
within the selection, which could lead to a paste error due to incompatible
range sizes.

HTH,
Bernie
MS Excel MVP

"Ryan" wrote in message
...
I'm trying to copy a range of data from sheet A and paste it into Sheet B,

then i'm trying to copy a range of data from a sheet C and paste it into the
next empty cell in Sheet B. so the data from C should paste right under the
data from A.

I'm getting an compiler error for the activesheet.paste statement at the

bottom.

can anyone tell me what is wrong.

tks.

Sub CollectData1()

Workbooks.Open Filename:= _
"G:\Credit\CSCASHSUM_VBA_V1.xls"
Sheets("CT").Select
Application.Goto Reference:="R1C1"
Range("A1").Select
Selection.CurrentRegion.Select
Selection.Copy
Windows("CS-Summary-Report.xls").Activate
Range("A2").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,

SkipBlanks:= _
False, Transpose:=False
Rows("2:2").Select
Selection.Font.Bold = True
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
End With
Cells.Select
Selection.Columns.AutoFit

Workbooks.Open Filename:= _
"G:\Credit\ComSwapsVBA.xls" _
, UpdateLinks:=0
Sheets("UNIQUE2").Select
Range("A1").Select
Selection.CurrentRegion.Select
Selection.Copy
Windows("CS-Summary-Report.xls").Activate

Worksheets("Sheet1").Cells(Rows.Count, 1).End(xlUp) _
.Offset(1, 0).Activate

ActiveSheet.Paste

End Sub





All times are GMT +1. The time now is 05:58 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com