Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Copying Variable Ranges

With Worksheets("Sheet2")
..Range(.Range("C1"), .Range("H1").End(xlDown)).Copy
End With
Range("K7").PasteSpecial

You need to qualify all range references to point to sheet2.

--
Regards,
Tom Ogilvy

"Alec" wrote in message
...
The following code works for copying a range from C1 up to
the first blank in column H;

Range("C1", Range("H1").End(xlDown)).Copy
Range("K7").PasteSpecial

But when I try the following code to copy the same amount
of data from sheet 2 I get an error message.

Worksheets("Sheet2").Range("C1", Range("H1").End
(xlDown)).Copy
Range("K7").PasteSpecial
Any ideas.
Thanks
Alec



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Copying Variable Ranges

Thanks Tom

This works fine with more than one row, but if the second
row is empty, I get the first three rows pasted instead of
just the first. Also if I just have one row I get the whole
65536 rows. Any ideas how this could be avoided.

Thanks Again
Alec

-----Original Message-----
With Worksheets("Sheet2")
..Range(.Range("C1"), .Range("H1").End(xlDown)).Copy
End With
Range("K7").PasteSpecial

You need to qualify all range references to point to

sheet2.

--
Regards,
Tom Ogilvy

"Alec" wrote in

message
...
The following code works for copying a range from C1 up

to
the first blank in column H;

Range("C1", Range("H1").End(xlDown)).Copy
Range("K7").PasteSpecial

But when I try the following code to copy the same

amount
of data from sheet 2 I get an error message.

Worksheets("Sheet2").Range("C1", Range("H1").End
(xlDown)).Copy
Range("K7").PasteSpecial
Any ideas.
Thanks
Alec



.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Copying Variable Ranges

With Worksheets("Sheet2")
..Range(.Range("C1"), .Range("H65536").End(xlUp)).Copy
End With
Range("K7").PasteSpecial

--
Regards,
Tom Ogilvy


"Alec" wrote in message
...
Thanks Tom

This works fine with more than one row, but if the second
row is empty, I get the first three rows pasted instead of
just the first. Also if I just have one row I get the whole
65536 rows. Any ideas how this could be avoided.

Thanks Again
Alec

-----Original Message-----
With Worksheets("Sheet2")
..Range(.Range("C1"), .Range("H1").End(xlDown)).Copy
End With
Range("K7").PasteSpecial

You need to qualify all range references to point to

sheet2.

--
Regards,
Tom Ogilvy

"Alec" wrote in

message
...
The following code works for copying a range from C1 up

to
the first blank in column H;

Range("C1", Range("H1").End(xlDown)).Copy
Range("K7").PasteSpecial

But when I try the following code to copy the same

amount
of data from sheet 2 I get an error message.

Worksheets("Sheet2").Range("C1", Range("H1").End
(xlDown)).Copy
Range("K7").PasteSpecial
Any ideas.
Thanks
Alec



.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Copying Variable Ranges

Thanks Again Tom


-----Original Message-----
With Worksheets("Sheet2")
..Range(.Range("C1"), .Range("H65536").End(xlUp)).Copy
End With
Range("K7").PasteSpecial

--
Regards,
Tom Ogilvy


"Alec" wrote in

message
...
Thanks Tom

This works fine with more than one row, but if the

second
row is empty, I get the first three rows pasted instead

of
just the first. Also if I just have one row I get the

whole
65536 rows. Any ideas how this could be avoided.

Thanks Again
Alec

-----Original Message-----
With Worksheets("Sheet2")
..Range(.Range("C1"), .Range("H1").End(xlDown)).Copy
End With
Range("K7").PasteSpecial

You need to qualify all range references to point to

sheet2.

--
Regards,
Tom Ogilvy

"Alec" wrote in

message
...
The following code works for copying a range from C1

up
to
the first blank in column H;

Range("C1", Range("H1").End(xlDown)).Copy
Range("K7").PasteSpecial

But when I try the following code to copy the same

amount
of data from sheet 2 I get an error message.

Worksheets("Sheet2").Range("C1", Range("H1").End
(xlDown)).Copy
Range("K7").PasteSpecial
Any ideas.
Thanks
Alec


.



.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
variable ranges gramps Excel Discussion (Misc queries) 4 February 4th 10 02:33 PM
Help with Variable Ranges! Nelson B. Excel Discussion (Misc queries) 1 August 21st 08 03:30 PM
Variable Ranges Erika Excel Worksheet Functions 1 November 30th 07 09:21 PM
Variable ranges John Contact Excel Worksheet Functions 1 June 17th 05 08:02 AM
Sum Variable Ranges Erika Excel Worksheet Functions 6 December 23rd 04 03:52 PM


All times are GMT +1. The time now is 10:37 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"