PasteSpecial Method of Range Class Failed Error a Different Ve
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...
|