View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Set CopyRange Error

There were more line wraps in the code you posted.

You actually have two logical lines in what you posted:

Set CopyRange = .Range("C" & c.Row & ":H" & c.Row)
and
CopyRange.Copy Destination:=Sheets("Sheet2").Range("C" & RowCount)

I'm not sure what the problem you're having is--or what the missing lines in
your code do.

But maybe something like:

with activesheet ' or with worksheets("Sheet9999") '<--change the name
Set CopyRange = .Range("C" & c.Row & ":H" & c.Row)
end with

copyrange.copy _
destination:=Sheets("Sheet2").Range("C" & RowCount)

(I like the .copy and destination:= on two different physical lines--even though
they're part of a single logical line.)

But all this depends on what the error is--and that could depend on what c is
and rowcount is...

Ty wrote:

I have another post but did not want to add more confusion with just
one line that I'm trying to resolve and understand. This line is
giving me an error when I try to execute:

Set CopyRange = _
.Range("C" & c.Row & ":H" & c.Row)
CopyRange.Copy Destination:=Sheets("Sheet2").Range("C"
&
RowCount)

I googled it and found the following:

Row Set CopyRange = Range("C1:C" & LastRowC) CopyRange.Copy
Destination:=Range("D" & NewRowD)

Is it the "_" underscore and "." period after the equal sign causing
the line to error?


--

Dave Peterson