tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,924
- Office Version
- 365
- 2019
- Platform
- Windows
Assume I have some data on Sheet1 as follows:
Using the code below, the last row evaluates to 6, correctly:
However, if the user were to apply a filter to the data first and only want Apples, using the code above evaluates to 2.
What I want is to some function to evaluate to 6, regardless of whether the user has applied a filter to the data.
I don't want to turn off the autofilter by adding:
because I assume the user wants to have the autofilter active.
Can it be done?
Thanks
Code:
Apples
Apples
Oranges
Pineapples
Peaches
Coconuts
Using the code below, the last row evaluates to 6, correctly:
Code:
Public Function LRow(ByRef wks As Worksheet) As Long
On Error GoTo Correction
With wks
LRow = .Cells.Find(What:="*", _
After:=.Cells(Rows.Count, Columns.Count), _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByRows).Row
End With
On Error GoTo 0
Exit Function
Correction:
LRow = 1
Resume Next
End Function
However, if the user were to apply a filter to the data first and only want Apples, using the code above evaluates to 2.
What I want is to some function to evaluate to 6, regardless of whether the user has applied a filter to the data.
I don't want to turn off the autofilter by adding:
Code:
Sheet1.AutoFilterMode = False
because I assume the user wants to have the autofilter active.
Can it be done?
Thanks