[PHP]yes, i agree.
this works if i call it from a cell like this:
PHP Code:
=filteredRange(tab_data[[Brands]:[Index]])
PHP Code:
Function filteredRange(theRange As Range) As String
Dim rng As Range
Dim r As Range
For Each r In theRange.Rows
If Not r.Hidden Then
If rng Is Nothing Then
Set rng = r
Else
Set rng = Union(rng, r)
End If
End If
Next
If Not rng Is Nothing Then filteredRange = rng.Address
End Function
as it is returning a String.
this works if i am returning a Count:
PHP Code:
Function filteredRange(theRange As Range) As Long
Dim rng As Range
Dim r As Range
Dim Cnt As Long
For Each r In theRange.Rows
If Not r.Hidden Then
If rng Is Nothing Then
Set rng = r
Cnt = 1
Else
Set rng = Union(rng, r)
Cnt = Cnt + 1
End If
End If
Next
If Not rng Is Nothing Then filteredRange = Cnt //do something with filteredRange
End Function
This works if function doesnt return a Range type but does find the visible range inside it:
PHP Code:
Function filteredRange(theRange As Range)
Dim rng As Range
Dim r As Range
For Each r In theRange.Rows
If Not r.Hidden Then
If rng Is Nothing Then
Set rng = r
Else
Set rng = Union(rng, r)
End If
End If
Next
If Not rng Is Nothing Then filteredRange = rng //do something with filteredRange
End Function
Cheers mate.
Bookmarks