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: 178
Default lastrow function help

I've been using Chip's (i believe) lastrow function for quite a while now and just ran into something strange in Office 2010:

if i have data in several columns, and a header row, and one column only has two options - AA or AB. I sort data by that column alphabetically a-z -
if i run lastrow on that sheet with no filter i get the true lastrow
if i filter only ab i get the true lastrow
if i filter only aa i get 1 as the result of lastrow?

here's the function for those unfamiliar:

Function LastRow(sh As Worksheet)
On Error Resume Next
'only looks for visible data, will not return hidden rows
'assign value for lastrow by finding
'What:="*" |ANY value
'after:=sh.range("a1") |anything after the first cell on the sheet
'Lookat:=xlPart |Match any portion of the cell value
'LookIn:=xlValues |Look in cell values instead of formulas
'SearchOrder:=xlByRows |Search by Rows, change to xlByColumns to search by Columns
'SearchDirection:=xlprevious |Search End to Beginning
'MatchCase:=False |Not Upper/Lowercase specific
'.Row |Return the Row value of that cell, change to .Column to return Column Value
LastRow = sh.Cells.Find( _
What:="*", _
After:=sh.Range("A1"), _
LookAt:=xlPart, _
LookIn:=xlValues, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False) _
.Row
On Error GoTo 0
End Function
 
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
Lastrow - function not defined seed Excel Discussion (Misc queries) 2 August 7th 08 06:34 PM
lastrow function okrob Excel Programming 4 February 21st 07 09:46 PM
Assistance with LASTROW function in VB Barb Reinhardt Excel Programming 8 November 28th 05 05:55 PM
LastRow function - #VALUE slc[_17_] Excel Programming 4 September 1st 05 09:47 PM
'LastRow' Function not working Randy Reese[_2_] Excel Programming 4 July 17th 04 03:44 AM


All times are GMT +1. The time now is 02:02 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"