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: 2,494
Default question on hiding rows

i have to loop through some rows and test to see which rows to hide. if i hide
the rows as i loop it takes 2 to 3 seconds to hide them. so i looked for a
better way.

as i loop, i create and array with a cell address of which rows i want to hide.
the only problem is, if the string is more than 256 characters, it won't work:
if this range contained more than 256 characters it wouldn't work
range("A6,A9,A12,A15").entirerow.hidden = true

so i wrote the code below and was wondering if there was a better way. this code
runs instantaneously, as opposed to 2 or 3 seconds to loop and hide each row 1
at a time.

it basically adds the cell address to a string until there are 50 address, then
it hides 50 rows at a time and resets the array. then what's less than 50 at the
end gets hidden when the loop exits.

data starts at row 5:

With ws
For x = 5 To lastrow
If .Range("G" & x).Value < 0 Or .Range("H" & x).Value < 0 _
Then
'do nothing
Else
ReDim Preserve arr(1 To x - 5)
arr(x - 5) = .Range("A" & x).Address(0, 0)
If cAddr = "" Then
cAddr = arr(x - 5)
Else
cAddr = cAddr & "," & arr(x - 5)
End If
If UBound(arr) Mod 50 = 0 Then
.Range(cAddr).EntireRow.Hidden = True
cAddr = ""
ReDim arr(1 To 1)
End If
End If
Next
ws.Range(cAddr).EntireRow.Hidden = True
End With
--


Gary



 
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
Basic VBA question - hiding rows Babymech Excel Discussion (Misc queries) 6 January 15th 09 01:28 PM
Color alternate rows when after hiding selected rows Monk[_2_] Excel Worksheet Functions 6 June 7th 08 01:36 AM
Hiding Specific Rows Based on Values in Other Rows Chris Excel Worksheet Functions 1 November 2nd 06 08:21 PM
Hiding a button when hiding rows fergusor Excel Discussion (Misc queries) 2 August 10th 06 02:31 PM
hiding Rows and buttons/comboxes, over the rows Ctech[_116_] Excel Programming 1 March 21st 06 12:38 PM


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

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

About Us

"It's about Microsoft Excel"