View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
isabelle isabelle is offline
external usenet poster
 
Posts: 587
Default Code Snippet - Data Filter

Sorry, this time i think i've thought of everything,
i had forgotten if the filter returns a single line, line 2

Sub Filter_first_last2()
Dim plg As Range, x As Variant, first As String, last As String
Set plg =
ActiveSheet.Range("_filterdatabase").SpecialCells( xlCellTypeVisible)

x = Split(plg.Address, ",")

last = Range(x(UBound(x))).Rows(Range(x(UBound(x))).Rows. Count).Row
'last row

If Range(x(0)).Rows.Count 1 Then
first = Range(x(0)).Rows(2).Row 'first row
Else
first = Range(x(1)).Row 'first row
End If

MsgBox "first: " & first & vbCrLf & "Last: " & last
End Sub

isabelle