Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copying a variable range


Hi!
I am trying to copy a range that always starts in row 3 but can vary in
how many rows down it goes (up to 40). I am currently using a series of
if thens and a count cell reference. I'm sure there is a much more
efficient method but I'm still a novice at this. Any help would be
appriciated.


--
Brian Matlack
------------------------------------------------------------------------
Brian Matlack's Profile: http://www.excelforum.com/member.php...fo&userid=3508
View this thread: http://www.excelforum.com/showthread...hreadid=476763

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 296
Default Copying a variable range

On Mon, 17 Oct 2005 07:02:50 -0500, Brian Matlack
wrote:


Hi!
I am trying to copy a range that always starts in row 3 but can vary in
how many rows down it goes (up to 40). I am currently using a series of
if thens and a count cell reference. I'm sure there is a much more
efficient method but I'm still a novice at this. Any help would be
appriciated.



Have you tried the CurrentRegion property of the Range object?

e.g. Range("A3").CurrentRegion

Rgd
__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Copying a variable range

Just a caution,

Current region could easily expand up to rows 2 and or 1 if there is data
there.

To test, select A3 and do Ctrl+Shift+8

and see what is selected.

--
Regards,
Tom Ogilvy


"Richard Buttrey" wrote in
message ...
On Mon, 17 Oct 2005 07:02:50 -0500, Brian Matlack
wrote:


Hi!
I am trying to copy a range that always starts in row 3 but can vary in
how many rows down it goes (up to 40). I am currently using a series of
if thens and a count cell reference. I'm sure there is a much more
efficient method but I'm still a novice at this. Any help would be
appriciated.



Have you tried the CurrentRegion property of the Range object?

e.g. Range("A3").CurrentRegion

Rgd
__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 296
Default Copying a variable range

On Mon, 17 Oct 2005 08:41:05 -0400, "Tom Ogilvy"
wrote:

Just a caution,

Current region could easily expand up to rows 2 and or 1 if there is data
there.

To test, select A3 and do Ctrl+Shift+8

and see what is selected.


Good point Tom. Caught me out a few times that one :-(

Cheers.
__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Copying a variable range

Dim rng as Range
set rng = Range(cells(3,1),cells(3,1).End(xldown))
rng.Entirerow.copy Destination:=worksheets("Sheet2").Range("A1")

--
Regards,
Tom Ogilvy

"Brian Matlack"
wrote in message
news:Brian.Matlack.1x1pac_1129550707.5155@excelfor um-nospam.com...

Hi!
I am trying to copy a range that always starts in row 3 but can vary in
how many rows down it goes (up to 40). I am currently using a series of
if thens and a count cell reference. I'm sure there is a much more
efficient method but I'm still a novice at this. Any help would be
appriciated.


--
Brian Matlack
------------------------------------------------------------------------
Brian Matlack's Profile:

http://www.excelforum.com/member.php...fo&userid=3508
View this thread: http://www.excelforum.com/showthread...hreadid=476763





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Copying a variable range

Ihave a thought,
before you record your macro have your cell anywhere but at the
beggining.
now click on record,(you must be in absolute mode) go to the top of the
row you want to copy ,(now,change the macro to relative mode) press
end-down to take you to the bottom of the row stop recording
test out your macro to see if it works

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copying a variable range


Thanks for all the help folks!! I think this help forum is great. I hope
someday I'm good enough to return the favors. Maybe this internet thing
is going to catch-on after all heh! Thanks again


--
Brian Matlack
------------------------------------------------------------------------
Brian Matlack's Profile: http://www.excelforum.com/member.php...fo&userid=3508
View this thread: http://www.excelforum.com/showthread...hreadid=476763

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
Copying a variable range of data from one worksheet to another. AllyB Excel Discussion (Misc queries) 3 March 2nd 09 11:37 PM
Macro for copying a value to a variable no. of rows Ian Grega Excel Discussion (Misc queries) 6 April 15th 08 02:48 PM
setting a range variable equal to the value of a string variable Pilgrim Excel Programming 2 July 1st 04 11:32 PM
Copying Variable Ranges Tom Ogilvy Excel Programming 3 October 21st 03 02:31 PM
Problem trying to us a range variable as an array variable TBA[_2_] Excel Programming 4 September 27th 03 02:56 PM


All times are GMT +1. The time now is 12:16 PM.

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"