LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA - Found last row number but can't select it

Hi there,

I am using the following code that I have been told is fairl
infallable at finding the last populated row of my data table. Th
routine Last_Row then displays the last row number. What I can'
manage to figure out how to do is actually select column A of the Las
row - sure it is simple but I am missing it.

Thanks

Andi

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

----------------------------------------------

Sub Show_Last_Row()
MsgBox LastCell(Sheet2).Cell

End Su

--
Message posted from http://www.ExcelForum.com

 
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
Extract number from cell when specific format is found paul c Excel Worksheet Functions 6 August 2nd 09 03:45 AM
Count the number of Commas found in cell A2 B~O~B Excel Worksheet Functions 3 April 2nd 08 05:27 PM
How to select the number in excel? Eric Excel Worksheet Functions 5 March 13th 06 06:58 AM
Advanced Filter: Number of Records Found Charlie Rowe Excel Discussion (Misc queries) 2 November 3rd 05 09:09 PM
is there someway to select what i have "found"? 1stpope New Users to Excel 1 March 16th 05 03:27 AM


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