LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Hiding Rows in a Range based on column A value

Why Not Filter the column

Sub Hide_with_Autofilter()
Dim HideValue As String
Dim rng As Range

HideValue = "ron"
' This will hide the rows with "ron" in the Range("A1:A100")
With ActiveSheet
.Range("A1:A100").AutoFilter Field:=1, Criteria1:=HideValue
With ActiveSheet.AutoFilter.Range
On Error Resume Next
Set rng = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.SpecialCells(xlCellTypeVisible)
On Error GoTo 0

End With
.AutoFilterMode = False
End With

If Not rng Is Nothing Then rng.EntireRow.Hidden = True

End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"tig" wrote in message oups.com...
Martin,

Thank you for the reply. The method you gave me works pretty well. So
I'm a little better off than I was earlier. The only problem is that
the range is usually over 1000 rows. So it takes quite a while to go
through the loop.

Any ideas on speeding it up?? One thing I thought of was to create a
named range with the rows with column A = 1, then I could just do
Range("test").Rows.Hidden = True.

My problem is I'm not sure if I can programmatically populate a named
range in a loop like that. And who knows, it might not even be much
faster.

Let me know if you have any further insights.

Thanks again.



 
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
Hiding rows in a range based on TRUE/FALSE value in each row michaelberrier Excel Discussion (Misc queries) 1 December 28th 06 10:33 PM
Hiding Specific Rows Based on Values in Other Rows Chris Excel Worksheet Functions 1 November 2nd 06 08:21 PM
Need help hiding/unhiding column based on autofilter selection in a different column kcleere Excel Programming 1 January 23rd 06 06:21 AM
Hiding rows based on a value John Excel Discussion (Misc queries) 1 July 2nd 05 08:44 PM
Hiding rows based on date Steve Excel Worksheet Functions 2 November 1st 04 02:30 PM


All times are GMT +1. The time now is 05:07 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"