View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ed Ed is offline
external usenet poster
 
Posts: 279
Default Referencing Cells in Multi-Area Range?

This may be a case of bludgeoning the problem to death, but I came up with a
reasonable solution to simple indexing of a multi-area range.

First I declared a new class, fliteredRange, with:

Public fRange As Excel.Range

Function fCells(ByVal r As Long, ByVal c As Long) As Range
Dim rSub As Range

For Each rSub In fRange.Areas
If r 0 And r <= rSub.Rows.Count Then
Set fCells = rSub.Cells(r, c)
Exit Function
End If
r = r - rSub.Rows.Count
Next rSub
set fCells = Nothing
End Function

Then I set a filteredRange object to the autofiltered cells:

Dim thing as new filteredRange
Set thing.fRange = xlSheet.AutoFilter.Range.SpecialCells(xlCellTypeVi sible)

and index it thusly:

thing.fCells(1,2)

It needs a little more error checking, but that's the essence.

Ed