Thread: Copy Method
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Copy Method

Rowan,

Just for interest, to avoid repetition of the mySht object, make it more
efficient, and more readable, I would code it as

With mySht
.Range(.Cells(5, 1), .Cells(endRow, 1)).Copy
'... rest of code
End With

Note the dots before Range and Cells.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Rowan" wrote in message
...
Thanks Jim, Bob

I was missing the fact that Cells refers to the activesheet only unless
referenced otherwise.

Regards
Rowan

"Rowan" wrote:

I was just wondering why this line of code works:

mySht.Range("A5:A" & endRow).Copy

while this one produces runtime error 1004

mySht.Range(Cells(5, 1), Cells(endRow, 1)).Copy

Regards
Rowan