View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Concise Way To Select All Rows Except First?

Actually, lastrow2 may give the wrong results.

If the .usedrange didn't start in A1 (or row 1), you could get the wrong answer.

If the only cell that was used was z99, then the usedrange.rows.count would be
equal to 1.

You could use:

dim LastRow2 as long
with activesheet.usedrange
lastrow2 = .rows(.rows.count).row
end with

=========
To the original poster:

You can do the same thing with an arbitrary range (single area???):

Dim myRng as range
dim LastRow as long
set myrng = activesheet.range("x9:z32")
with myrng
lastrow = .rows(.rows.count).row
end with
msgbox myrng.row & vblf & lastrow



Mike H wrote:

Hi,

here's a few ways

Lastrow1 = Cells(Cells.Rows.Count, "A").End(xlUp).Row

Lastrow2 = ActiveSheet.UsedRange.Rows.Count

LastRow3 = Cells.Find("*", SearchOrder:=xlByRows,
SearchDirection:=xlPrevious).Row

Mike

"PeteCresswell" wrote:

I guess I want to concoct a .Range and then operate on it.

But, short of iterating thorugh rows to find the last row, I can't
figure out how to do it.

Googled a little, and "ActiveCell.SpecialCells(xlLastCell) seems to
have the right ring to it.

True?

Either way, can somebody shed some light?


--

Dave Peterson