Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Alok, your code works. Timings:-3000 rows 0.40.0, 6000 rows 0.26.9, 12000 rows
2:00.8, 20160 rows 2:00.9 Dana, I tried your code on 3,204 rows it takes 0:18:0 but at each repeat processing (ie I unhid the rows and ran again) the time increments by about 7secs. Just curious why. Tom, when I copied your code,"..Set rng= Sheet1.Cells(i,1) "E" .." turned red. Did not proceed. RobertR "Dana DeLouis" wrote: Here's are just some additional ideas... Sub HideRows() Dim Cell As Range Const str_x As String = "x" For Each Cell In Range("E5:E204").Cells Cell.EntireRow.Hidden = (Cell = str_x) And (Cell(1, 4) = str_x) Next End Sub Sub HideRows_v2() Dim R As Long '(R)ow Const str_x As String = "x" For R = 5 To 204 Rows(R).Hidden = (Cells(R, 5) = str_x) And (Cells(R, 8) = str_x) Next End Sub -- Dana DeLouis Win XP & Office 2003 "thom hoyle" wrote in message ... Here is a piece of code I'm using to hide rows that have an "x" in two of the columns. Is there a more efficient way to write this. thanks Sub HideRows() Application.ScreenUpdating = False Dim rng As Range Dim i As Long Set rng = Range("E5:E204") i = 0 'set up a variable to see if range contains hidden rows For Each c In rng If c.EntireRow.Hidden = True Then c.EntireRow.Hidden = False i = 1 End If Next If i = 1 Then 'if any hidden rows unhide Application.ScreenUpdating = True Exit Sub End If For Each c In rng 'if no hidden rows unhidden then hide If c.Value = "x" And c.Offset(0, 3).Value = "x" Then c.EntireRow.Hidden = True End If Next Application.ScreenUpdating = True End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
making code more efficient | Excel Discussion (Misc queries) | |||
Which is more efficient? | Excel Programming | |||
Making code more efficient | Excel Programming | |||
Book on how to write VBA code in a fast/efficient manner? | Excel Programming | |||
More efficient code | Excel Programming |