#1   Report Post  
Posted to microsoft.public.excel.misc
Alberto Pinto
 
Posts: n/a
Default Last filled row

Hi!

How can I know what is the last row filled with sometinhg on a page.
I want to get always the last row of a list but that list is variable.

Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.misc
Paul Lautman
 
Posts: n/a
Default Last filled row

Alberto Pinto wrote:
Hi!

How can I know what is the last row filled with sometinhg on a page.
I want to get always the last row of a list but that list is variable.

Thanks in advance.


Are you talking in VBA? If so here is a function and a sub:

Sub LastCell()
'Ctrl-L


On Error GoTo blanksheet


Cells(Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByRows).Row, _
Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByColumns).Column).Select
Exit Sub
blanksheet:
Range("A1").Select
End Sub

Function lc(ws As Worksheet) As Range
Dim LastRow&, LastCol%

' Error-handling is here in case there is not any
' data in the worksheet

On Error GoTo blanksheet

With ws

' Find the last real row

LastRow& = .Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByRows).Row

' Find the last real column

LastCol% = .Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByColumns).Column

End With

' Finally, initialize a Range object variable for
' the last populated row.

Set lc = ws.Cells(LastRow&, LastCol%)
Exit Function
blanksheet:
Set lc = ws.Cells(1, 1)

End Function


  #3   Report Post  
Posted to microsoft.public.excel.misc
Alberto Pinto
 
Posts: n/a
Default Last filled row

No, indeed not. I was talking in Excel functions

Paul Lautman wrote:
Alberto Pinto wrote:
Hi!

How can I know what is the last row filled with sometinhg on a page.
I want to get always the last row of a list but that list is variable.

Thanks in advance.


Are you talking in VBA? If so here is a function and a sub:

Sub LastCell()
'Ctrl-L


On Error GoTo blanksheet


Cells(Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByRows).Row, _
Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByColumns).Column).Select
Exit Sub
blanksheet:
Range("A1").Select
End Sub

Function lc(ws As Worksheet) As Range
Dim LastRow&, LastCol%

' Error-handling is here in case there is not any
' data in the worksheet

On Error GoTo blanksheet

With ws

' Find the last real row

LastRow& = .Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByRows).Row

' Find the last real column

LastCol% = .Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByColumns).Column

End With

' Finally, initialize a Range object variable for
' the last populated row.

Set lc = ws.Cells(LastRow&, LastCol%)
Exit Function
blanksheet:
Set lc = ws.Cells(1, 1)

End Function


  #4   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default Last filled row


=LOOKUP(2,1/(A1:A1000<""),A1:A1000)

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Alberto Pinto" wrote in message
...
Hi!

How can I know what is the last row filled with sometinhg on a page.
I want to get always the last row of a list but that list is variable.

Thanks in advance.



  #5   Report Post  
Posted to microsoft.public.excel.misc
Alberto Pinto
 
Posts: n/a
Default Last filled row

thanks but this doesn't work. Don't you know any other way?

Alberto

Bob Phillips wrote:
=LOOKUP(2,1/(A1:A1000<""),A1:A1000)

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Alberto Pinto" wrote in message
...
Hi!

How can I know what is the last row filled with sometinhg on a page.
I want to get always the last row of a list but that list is variable.

Thanks in advance.





  #6   Report Post  
Posted to microsoft.public.excel.misc
Paul Lautman
 
Posts: n/a
Default Last filled row

If this list is contiguous in a column then =COUNTA(A:A) will tell you the
row number and
=OFFSET(A1,COUNTA(A:A)-1,0,1,1) will give you the value.

Alberto Pinto wrote:
thanks but this doesn't work. Don't you know any other way?

Alberto

Bob Phillips wrote:
=LOOKUP(2,1/(A1:A1000<""),A1:A1000)

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Alberto Pinto" wrote in message
...
Hi!

How can I know what is the last row filled with sometinhg on a page.
I want to get always the last row of a list but that list is
variable. Thanks in advance.




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
Excell - How do I "force" cell to be filled or return error mge. NeedHelp-Thanks! Excel Worksheet Functions 0 June 29th 05 02:39 PM
Counting blank and filled cells within a range. greg7468 Excel Discussion (Misc queries) 3 June 28th 05 10:41 PM
How do I only calculate cells which have a filled color format? Phillip Bruce Excel Discussion (Misc queries) 1 June 23rd 05 08:07 PM
Macro that copy page to page just some filled cells LC Excel Discussion (Misc queries) 0 May 13th 05 11:22 PM
Return number of cells filled LMB New Users to Excel 3 April 29th 05 02:55 AM


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