Expand/Collapse Rows

G

gammay

Hi, I am writing a macro to expand/collapse a group of rows.

Requirement:
The excel sheet contains test cases. The test cases are grouped into
different categories. For easy viewing of the test cases, I need to
collapse the entire category of test cases. The category name comes
first on a separate row followed by several rows of test cases - test
cases can be any number and people can keep on adding/removing cases.

I have put small buttons with names '+', '-' and mapped to macros to
hide and unhide rows. This works well (See macros HideR, UnhideR below)

The problem:
I dont want to hardcode the row numbers as the row numbers can keep on
changing. I am mainly creating a test cases template which will be used
by others. They should not go about editing macros. Their job is just
to add/modify test cases and the +, - buttons should still work.

I have thought of the following solution, but I am not sure how to go
about implementing this and need help here.
The macro could collapse all the rows from the current row/cell (where
the buttons are located) until a fixed pattern is matched (say, "END
SECTION"). The buttons can then be placed on the same row as the
category header. At the end of the section the "END SECTION" will be
placed. Rows can be added/deleted in between and the macros would still
work. Is this possible?

cheers,
Girish


----------------------------------------------------------------------------------
Sub HideR()
Rows("6:13").Select
Selection.EntireRow.Hidden = True
End Sub

Sub UnhideR()
Rows("6:13").Select
Selection.EntireRow.Hidden = False
End Sub
----------------------------------------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top