Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Lastrow - function not defined | Excel Discussion (Misc queries) | |||
lastrow function | Excel Programming | |||
Assistance with LASTROW function in VB | Excel Programming | |||
LastRow function - #VALUE | Excel Programming | |||
'LastRow' Function not working | Excel Programming |