Error 1004 when copying and pasting values

R

Romanian37

All,

A co-worker has just had a macro (which has been working for the las
year) crash at the last line of code shown below. The error is 1004 an
suggests that the copy/paste areas are not the same, even though the
obviously are.

Any ideas?
Thanks

Will



Range(Cells(2, 12), Cells(2, 20)).Select
Selection.Copy
Range(Cells(3, 12), Cells(EndRow, 20)).Select
Selection.PasteSpecial Paste:=xlFormulas
Calculate

Range(Cells(3, 12), Cells(EndRow, 20)).Select
Selection.Copy
'breaks here
Selection.PasteSpecial Paste:=xlValue
 
D

Dave Peterson

But I think it's only obvious to those who know what EndRow is????

You could just paste to the topleft corner of the "to" range. Excel will resize
to match the copied range.

Range(Cells(2, 12), Cells(2, 20)).Copy
Cells(3, 12).PasteSpecial Paste:=xlFormulas
Calculate

(if it wasn't the mergedcells stuff that Frank suggested.)
 
R

Romanian37

Thanks for the thoughts.

The selection contains no merged cells.

The strange thing is that it breaks, not at the past special formula
section (where you could expect the sizing problem to kick in), bu
instead in the pastespecial values section, where it has copied th
selection and immediately pastes over same section (the selectio
contains no merged cells).

The outcome so far, has been that the computer was shut down ove
night, and the problem has not recurred this morning, so could it be
hardware or other non-code problem
 
Top