Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default how to find the last line?

how can i find the number of the last line of a sheet??
urgent, please!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default how to find the last line?

By last line, do you mean the last line that contains data? Press Ctrl+End.


"italo" wrote in message
...
how can i find the number of the last line of a sheet??
urgent, please!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default how to find the last line?

This will give you the row number of the last row in column A.

msgbox cells(rows.count, "A").end(xlup).row
--
HTH...

Jim Thomlinson


"italo" wrote:

how can i find the number of the last line of a sheet??
urgent, please!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default how to find the last line?

Hi italo,

You could try: ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell) .Row

or use the following function:

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

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

On Error Resume Next

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 LastCell = ws.Cells(LastRow&, LastCol%)

End Function

To use the above function:

LastCell(Worksheets("Your Worksheet Name")).row
or
LastCell(ActiveSheet).row

Hope this helps,

Chris

"italo" wrote in message
...
how can i find the number of the last line of a sheet??
urgent, please!



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default how to find the last line?

Here you go...

iLastRow = UBound(ActiveSheet.UsedRange.Value2, 1) +
ActiveSheet.UsedRange.Row - 1

iLastColumn = UBound(ActiveSheet.UsedRange.Value2, 2) +
ActiveSheet.UsedRange.Column - 1

-Kent


italo wrote:
how can i find the number of the last line of a sheet??
urgent, please!




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
find next line for data entry Decreenisi Excel Worksheet Functions 4 December 3rd 07 06:12 PM
Find and Replace where there are line breaks radellaf Excel Discussion (Misc queries) 3 August 24th 07 02:45 PM
How do I find a value on a line? brendas182 Charts and Charting in Excel 2 June 10th 05 02:35 PM
find out line count source in vbe tom cang Excel Programming 0 November 26th 04 04:31 AM
Macro to find the next free line Madasu Excel Programming 5 August 26th 04 02:08 AM


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