Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Turn off Autofilter but leave rows hidden.

How about leaving the filter active, but hiding the filter arrows?

Debra Dalgleish shows how:
http://contextures.com/xlautofilter03.html#Hide



GollyJer wrote:

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


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Turn off Autofilter but leave rows hidden.

Thanks Dave. I have tried that. It still looks weird to the user because
of the blue row numbers (vs. the normal black). If speed becomes the
absolute decision maker I think using autofilter and hiding the filter arrow
would be the solution.

"Dave Peterson" wrote in message
...
How about leaving the filter active, but hiding the filter arrows?

Debra Dalgleish shows how:
http://contextures.com/xlautofilter03.html#Hide



GollyJer wrote:

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


--

Dave Peterson


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Turn off Autofilter but leave rows hidden.

I guess you could loop through the values in column B:

Dim myCell As Range
Dim myRng As Range

With ActiveSheet
Set myRng = .Range("B2", .Cells(.Rows.Count, "B").End(xlUp))

For Each myCell In myRng.Cells
If IsError(myCell.Value) Then
myCell.EntireRow.Hidden = True
Else
Select Case LCase(myCell.Text)
Case "n/a", "0"
myCell.EntireRow.Hidden = True
Case Else
myCell.EntireRow.Hidden = False
End Select
End If
Next myCell
End With

Did you mean "#n/a" or "n/a"????

But it's not possible to remove the autofilter while keeping those filtered rows
hidden.


GollyJer wrote:

Thanks Dave. I have tried that. It still looks weird to the user because
of the blue row numbers (vs. the normal black). If speed becomes the
absolute decision maker I think using autofilter and hiding the filter arrow
would be the solution.

"Dave Peterson" wrote in message
...
How about leaving the filter active, but hiding the filter arrows?

Debra Dalgleish shows how:
http://contextures.com/xlautofilter03.html#Hide



GollyJer wrote:

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


--

Dave Peterson


--

Dave Peterson
Reply
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 01:22 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"