View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Maury Markowitz[_2_] Maury Markowitz[_2_] is offline
external usenet poster
 
Posts: 119
Default Rows won't hide?

I have a large sheet with with some headers and totals at the top.
Some of the rows are needed for information, but shouldn't be
displayed on the screen. At the end of generating the sheet, I loop
over the lines and set these rows to 0 RowHeight.

Each group of lines also has a separate header line, otherwise blank.
If all of the details lines are hidden, I want to the header line to
hide too. So I did this...

i = 5
While i < lastRow
' see if this is a program, and where it starts and ends
pstart = ast.Range("FD" & i)
pend = ast.Range("FE" & i)
If IsEmpty(pstart) Or IsEmpty(pend) Then GoTo
TRYHIDINGNEXTPROG

' check the row height, assuming this will return something
useful,
' and then hide the program header
h = ast.Range("A" & pstart & ":A" & pend).RowHeight
If IsNull(h) Or h = 0 Then
ast.Rows(pstart - 1).RowHeight = 0
End If

' we've checked this program, move onto the next one
i = pend

TRYHIDINGNEXTPROG:
i = i + 1
Wend

pstart and pend are accurate recordings of the start and end of every
group. When I run the above code, many of the "empty groups" do hide
properly, but a small number don't. When I loop through the code by
hand looking for the problem, it works perfectly every time. I can't
find the problem no matter what I do.

Can anyone suggest a reason for this behavior?

Maury