|
| ||||||||||
| Tags: excel, find, office 2007 |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| ||||
| ||||
| How to find the last row of Excel 2007
|
|
#2
| ||||
| ||||
| Re: How to find the last row of Excel 2007
To find the last Row on an Excel Worksheet using VBA: Code: Sub FindLastRow() Dim LastRow As Long If WorksheetFunction.CountA(Cells) > 0 Then 'Search for any entry, by searching backwards by Rows. LastRow = Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row MsgBox LastRow End If End Sub |
|
#3
| ||||
| ||||
| Re: How to find the last row of Excel 2007
In fact there are two ways to achieve this. Here it is: LastRow = Cells.Find ("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious). Row or LastRow = ActiveSheet.UsedRange.Rows.Count The second one is more reliable because the first statement won’t work on filtered Excel Worksheet since the code returns the position of the last row which is not filtered. |
|
#4
| ||||
| ||||
| Re: How to find the last row of Excel 2007
Here is what you want: Code: Private Function FindLastRow() As String
Dim LastRow As Long
Dim FirstCell As Range
If objExcel.WorksheetFunction.CountA(objExcel.Cells) > 0 Then
'Search for any entry, by searching backwards by Rows.
LastRow = objExcel.Cells.Find(What:="*", After:=objExcel.Range("A1"), _
searchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
End If
Set FirstCell = objExcel.Cells(LastRow, 1)
End Function |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "How to find the last row of Excel 2007" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| integrating find tool in a cell referring another workbook in MS-excel 2007 | shyra_grace | Windows Software | 1 | 10-04-2012 11:12 PM |
| Find / Replace in Excel 2007 | KALANI84 | Windows Software | 4 | 21-03-2012 01:32 AM |
| Excel 2007 file fails to get permission to open in Excel 2011 | Raju Chacha | Windows Software | 6 | 13-01-2012 08:17 PM |
| How to check data validation compatibility of excel 2010 on excel 2007 | Zoello | Windows Software | 6 | 17-05-2011 10:00 PM |
| Cannot find macro working in excel 2007 | Visala | Windows Software | 3 | 06-08-2009 11:47 PM |