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

In the following code is it possible to use the actual number of
filled-in rows instead of hard-coded maximum of 15,000?

Workbooks.Open FileName:=sDbf
Range("2:15000").Select
Selection.Copy
Destination:=ThisWorkbook.Sheets(sWSName).Range("2 :15000")
ActiveWorkbook.Close

May be something with Rows.Count?

If it matters I'm working with Excel 2002.

TIA, Eugene
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Select and copy a variable range

Hi Eugene

I think this is what you need:

Workbooks.Open Filename:=sDbf
LastRow = Range("A65536").End(xlUp).Row
Rows("2:" & LastRow).Copy
Destination:=ThisWorkbook.Sheets(sWSName).Rows("2" )
ActiveWorkbook.Close

Regards;
Per

On 29 Aug., 20:08, "E. F." wrote:
In the following code is it possible to use the actual number of
filled-in rows instead of hard-coded maximum of 15,000?

* * * * Workbooks.Open FileName:=sDbf
* * * * Range("2:15000").Select
* * * * Selection.Copy
Destination:=ThisWorkbook.Sheets(sWSName).Range("2 :15000")
* * * * ActiveWorkbook.Close

May be something with Rows.Count?

If it matters I'm working with Excel 2002.

TIA, Eugene


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Select and copy a variable range

Thank you for the prompt response.

Is Range("A65536") equivalent to Range("A" & Rows.Count)?

TIA, Eugene
================================================== ==============

On Aug 29, 2:36*pm, Per Jessen wrote:
Hi Eugene

I think this is what you need:

Workbooks.Open Filename:=sDbf
* * * * LastRow = Range("A65536").End(xlUp).Row
* * * * Rows("2:" & LastRow).Copy
Destination:=ThisWorkbook.Sheets(sWSName).Rows("2" )
* * * * ActiveWorkbook.Close

Regards;
Per

On 29 Aug., 20:08, "E. F." wrote:



In the following code is it possible to use the actual number of
filled-in rows instead of hard-coded maximum of 15,000?


* * * * Workbooks.Open FileName:=sDbf
* * * * Range("2:15000").Select
* * * * Selection.Copy
Destination:=ThisWorkbook.Sheets(sWSName).Range("2 :15000")
* * * * ActiveWorkbook.Close


May be something with Rows.Count?


If it matters I'm working with Excel 2002.


TIA, Eugene- Hide quoted text -


- Show quoted text -


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Select and copy a variable range

It is in xl97-xl2003.

xl95 and previous had 16k rows (if I remember correctly).

xl2007 has 1MB rows.



"E. F." wrote:

Thank you for the prompt response.

Is Range("A65536") equivalent to Range("A" & Rows.Count)?

TIA, Eugene
================================================== ==============

On Aug 29, 2:36 pm, Per Jessen wrote:
Hi Eugene

I think this is what you need:

Workbooks.Open Filename:=sDbf
LastRow = Range("A65536").End(xlUp).Row
Rows("2:" & LastRow).Copy
Destination:=ThisWorkbook.Sheets(sWSName).Rows("2" )
ActiveWorkbook.Close

Regards;
Per

On 29 Aug., 20:08, "E. F." wrote:



In the following code is it possible to use the actual number of
filled-in rows instead of hard-coded maximum of 15,000?


Workbooks.Open FileName:=sDbf
Range("2:15000").Select
Selection.Copy
Destination:=ThisWorkbook.Sheets(sWSName).Range("2 :15000")
ActiveWorkbook.Close


May be something with Rows.Count?


If it matters I'm working with Excel 2002.


TIA, Eugene- Hide quoted text -


- Show quoted text -


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Select and copy a variable range

Dave,

Thank you very much for the clarification.

Eugene
==============================================
On Aug 29, 6:05*pm, Dave Peterson wrote:
It is in xl97-xl2003.

xl95 and previous had 16k rows (if I remember correctly).

xl2007 has 1MB rows.





"E. F." wrote:

Thank you for the prompt response.


Is Range("A65536") equivalent to Range("A" & Rows.Count)?


TIA, Eugene

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
Select a variable range Bluecat Excel Worksheet Functions 7 January 13th 09 01:24 AM
Select variable range ewan7279 Excel Programming 1 September 5th 07 09:46 AM
Select a variable range Eduardo Excel Programming 7 August 8th 07 01:46 PM
Use a Variable to select a range Connie Excel Discussion (Misc queries) 3 October 19th 06 05:48 PM
select a variable range evil baby[_15_] Excel Programming 4 March 8th 06 08:38 PM


All times are GMT +1. The time now is 11:42 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"