View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Per Jessen[_2_] Per Jessen[_2_] is offline
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