View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
stevec stevec is offline
external usenet poster
 
Posts: 177
Default PasteSpecial Method of Range Class Failed Error a Different Ve

OssieMac and JMB... thanks very much

"JMB" wrote:

Not sure why you would have to repeat the copy method - it worked okay for me
(except for the xlPasteColumnWidths - I'm using XL2000 which does not support
it. I assume you're using a later version that does). Unless this line is
in the wrong place:
Application.CutCopyMode = False
or there is something else going on in-between that turns off copymode?

I expect your error was just as Ossiemac said, the entire worksheet was
being pasted so it would fail if A1 was not the active cell on the
destination worksheet.

I don't work w/Charts much - so I can't help you much w/that.



"SteveC" wrote:

JMB that works better -- no error for me now... but I had to put this:

Workbooks("Book2").Sheets("Sheet1").Cells.Copy

before each PasteSpecial code for it to work (otherwise I would only paste
values, not format for some reason).

Separately, any cluue how to copy charts on the original worksheet and paste
into another worksheet as a picture? Right now the macro you provided
doesn't copy and paste charts... thanks very much for your help... SteveC

"JMB" wrote:

As a side note - it is almost never necessary to select or activate anything

Sub test()
Const ShName As String = "Sheet3"

Workbooks("Book2").Sheets("Sheet1").Cells.Copy
'Or you could copy just the used range
'Workbooks("Book2").Sheets("Sheet1").UsedRange.Cop y

With ThisWorkbook.Sheets(ShName).Range("A1")
.PasteSpecial _
Paste:=xlPasteValues, _
Operation:=xlNone, _
skipBlanks:=False, _
Transpose:=False

.PasteSpecial _
Paste:=xlPasteFormats, _
Operation:=xlNone, _
skipBlanks:=False, _
Transpose:=False

.PasteSpecial _
Paste:=xlPasteColumnWidths, _
Operation:=xlNone, _
skipBlanks:=False, _
Transpose:=False
End With

Application.CutCopyMode = False

End Sub



"SteveC" wrote:



Below is a snippet of code taken from a larger piece of code.

A get a runtime error with the line under "ActiveSheet.Paste" highlighted in
the debugger:

Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

any help? can't figure out how to use similar responses on the discussion
groups to fix... thanks very much.

SteveC

starting code... then


Range("A1:IV65536").Select
Selection.Copy
ThisWorkbook.Activate
Sheets(ShName).Select

ActiveSheet.Paste

Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

Selection.PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

Range("A1").Select

code continues...