Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Raj Raj is offline
external usenet poster
 
Posts: 130
Default macro code to find last record in excel

Hi
Please send me an example code to get the last record number in a worksheet
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default macro code to find last record in excel

Raj:

What do you mean by the last record number.

Excel is not a database is it a spreadsheet.

If you mean the last row in the speadsheet then:

activesheet.cells.rows.count

if you mean the last row with some entry on it then:

activesheet.usedrange.row + activesheet.usedrange.rows.count - 1

--

Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


"Raj" wrote:

Hi
Please send me an example code to get the last record number in a worksheet

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default macro code to find last record in excel

MsgBVox Cells(LastRow,LastCol).Value





'-----------------------------------------------------------------
Function LastRow() As Long
'-----------------------------------------------------------------
LastRow = Cells.Find(What:="*", _
After:=Range("A1"), _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
End Function

'-----------------------------------------------------------------
Function LastCol() As Long
'-----------------------------------------------------------------
LastCol = Cells.Find(What:="*", _
After:=Range("A1"), _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
End Function




--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Raj" wrote in message
...
Hi
Please send me an example code to get the last record number in a

worksheet


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
Macro to find and record Unique values? Arlen Excel Discussion (Misc queries) 7 July 18th 08 01:07 PM
Why doesn't Excel 2007 record charting and office art macro code? NOLuckMatt Excel Discussion (Misc queries) 0 August 17th 07 02:38 PM
find last record in macro and delete all after Sherife Excel Programming 3 September 18th 06 03:58 AM
find last record in macro and delete all after Sherife Excel Discussion (Misc queries) 3 September 18th 06 03:51 AM
vba code to record a macro green fox Excel Programming 2 January 11th 06 09:46 PM


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