#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Last Row

How can i find the last row on a worksheet ?

on a worksheet the first row is row7 and i also want to find last row in a
formula.



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Last Row

Birdy,

I assume you mean the last row with data. This code finds the last row with
data in column A, and caters for embedded blank rows.

cLastRow = Worksheets("Sheet1").Cels(Rows.Count,"A").End(xlUp ).Row

If you want the first free row, just add 1.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Birdy" wrote in message
.nl...
How can i find the last row on a worksheet ?

on a worksheet the first row is row7 and i also want to find last row in a
formula.





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Last Row

Hi
in VBA:
Dim rng as range
set rng = Cells(1,1).End(xldown)

--
Regards
Frank Kabel
Frankfurt, Germany

Birdy wrote:
How can i find the last row on a worksheet ?

on a worksheet the first row is row7 and i also want to find last row
in a formula.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Last Row

Hi Birdy

If you can't check one column like in Bob's example then
for the last row with data on your worksheet you can use this

Sub test()
MsgBox LastRow(ActiveSheet)
End Sub

Function LastRow(sh As Worksheet)
On Error Resume Next
LastRow = sh.Cells.Find(What:="*", _
After:=sh.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
On Error GoTo 0
End Function


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Birdy" wrote in message .nl...
How can i find the last row on a worksheet ?

on a worksheet the first row is row7 and i also want to find last row in a
formula.





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



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