Sure, it can be done. But I can't tell you how to do it ELEGANTLY.
First, know the range you are working with. Best way to know what it
is ... select one cell then find the entire data table by:
Set myRange = Range(one cell in data table).CurrentRegion
Second, determine the number of rows in that range:
LastRow = myRange.Cells(myRange.Cells.Count).row
Third, apply your filter.
myRange.Select
Selection.AutoFilter Field:=??, Criteria1:="????"
where ?? is the number of the column and ???? is the filter you want to
apply
Next, find out which rows are visible.
n = 0
For i = FirstRow to LastRow
If cells(i, ??).entirerow.hidden = false then
n = n + 1
vizRows(n) = i
End if
Next i
Now, turn off the filter:
If ActiveSheet.FilterMode = True Then ActiveSheet.AutoFilterMode =
False
Now, hide all rows.
myRange.entirerow.hidden = True
Now, unhide all rows that you want to unhide:
For i = 1 to n
cells(vizRows(n)-1, 1).entirerow.hidden = false
cells(vizRows(n), 1).entirerow.hidden = false
cells(vizRows(n)+1, 1).entirerow.hidden = false
next i
---
Message posted from
http://www.ExcelForum.com/