LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Turn off Autofilter but leave rows hidden.

Is there any way to turn off an Autofilter and leave the rows hidden?

I use the following method for showing hiding rows. Its very fast and
doesn't do anything if not needed (all need to show are showing and all need
to hide are hidden). There's a helper column (B) that contains an error,
"N/A", or a zero "0".

Screen updating and calculation are turned off when these methods run.

--------------------------------------------------------------------------------------
Sub SetRowVisibility()

Dim rowsToCheck As Range
With ActiveSheet
Set rowsToCheck = .Range(Range("B7"), Range("B7").End(xlDown))
End With

Dim needToShow As Range, needToShow_Showing As Range
Dim needToHide As Range, needToHide_Showing As Range

Set needToShow = rowsToCheck.SpecialCells(xlCellTypeFormulas, xlNumbers)
Set needToHide = rowsToCheck.SpecialCells(xlCellTypeFormulas, xlErrors)

On Error Resume Next
Set needToShow_Showing = needToShow.Offset(0,
1).SpecialCells(xlCellTypeVisible)
Set needToHide_Showing = needToHide.Offset(0,
1).SpecialCells(xlCellTypeVisible)
On Error GoTo 0

'Hide only if needed and not hidden.
If Not needToHide_Showing Is Nothing Then
needToHide_Showing.EntireRow.Hidden = True
End If

'Show only if needed and not showing.
If Not needToShow Is Nothing Then
If needToShow.Count < needToShow_Showing.Count Then
needToShow.EntireRow.Hidden = False
End If
End If

End Sub
--------------------------------------------------------------------------------------


I'd like to use the Autofilter but this is the best I can do. It always has
to filter the data to run.
--------------------------------------------------------------------------------------
Sub SetRowVisibility2()
Dim needToShow As Range, needToHide As Range

With ActiveSheet.Range(Range("B7"), Range("B7").End(xlDown))

On Error Resume Next
.AutoFilter Field:=1, Criteria1:="0"
Set needToShow = .SpecialCells(xlCellTypeVisible)

.AutoFilter Field:=1, Criteria1:="#N/A"
Set needToHide = .SpecialCells(xlCellTypeVisible)

ActiveSheet.AutoFilterMode = False

needToShow.EntireRow.Hidden = False
needToHide.EntireRow.Hidden = True

End With

End Sub
--------------------------------------------------------------------------------------

The ideal solution would be to filter using the Autofilter, turn off the
Autofilter and leave the filtered cells hidden. Possible?

Thanks,
Jeremy

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Rows hidden by Autofilter vs hidden by changing the Hidden property LEO@KCC Excel Programming 4 September 11th 07 10:14 AM
How can I shade every other row with some rows hidden (autofilter dlindamood Excel Programming 1 March 27th 06 12:38 AM
AutoFilter & Hidden Rows John[_88_] Excel Programming 2 July 22nd 04 03:28 AM
AutoFilter and Hidden Rows Greg Bloom Excel Programming 1 September 25th 03 11:16 PM
Leave hidden rows out of sum Eva Shanley Excel Programming 6 September 12th 03 06:04 PM


All times are GMT +1. The time now is 07:54 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"