Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to Outline based on Indent Level
I have a worksheet with column B being titles that are indented to
outline the list (I even have the indent level a column). I would like to outline this with VBA with a macro, so I can hide and show the details as necessary. Can anyone help me with how to set up the loops to search and determine the first and last rows of the group. My summary row is above. I know how to group and outline rows manually and have recorded it. The issue is I want to be able to automate the process for future versions. I also add and delete rows which causes outlining errors. Example Row Description indent LevelMore columns 1 Desc 1 0 1 Desc 1 1 1 Desc 1 2 1 Desc 1 2 1 Desc 1 1 1 Desc 1 2 1 Desc 1 2 1 Desc 1 2 1 Desc 1 0 1 Desc 1 1 1 Desc 1 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to Outline based on Indent Level
Hope this helps. You can remove idents by use negaive numbers for
identlevel. You will get an error 1004 if you go under 1. If the ident level is two you can one use identlevel -1 (-2 will give the error). Sub Macro1() ' ' Macro1 Macro ' Macro recorded 4/13/2007 by Joel Warburg ' 'Ident text For RowCount = 1 To 10 Range("A" & CStr(RowCount)).InsertIndent RowCount Next RowCount 'read ident level For RowCount = 1 To 10 MsgBox (CStr(Range("A" & CStr(RowCount)).IndentLevel)) Next RowCount End Sub " wrote: I have a worksheet with column B being titles that are indented to outline the list (I even have the indent level a column). I would like to outline this with VBA with a macro, so I can hide and show the details as necessary. Can anyone help me with how to set up the loops to search and determine the first and last rows of the group. My summary row is above. I know how to group and outline rows manually and have recorded it. The issue is I want to be able to automate the process for future versions. I also add and delete rows which causes outlining errors. Example Row Description indent LevelMore columns 1 Desc 1 0 1 Desc 1 1 1 Desc 1 2 1 Desc 1 2 1 Desc 1 1 1 Desc 1 2 1 Desc 1 2 1 Desc 1 2 1 Desc 1 0 1 Desc 1 1 1 Desc 1 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to Outline based on Indent Level
Joel,
Sorry for the confusion. the example below is what I already have. I want to be able to use the "Outline" ability of Excel to hide an show the subordanate rows. To the left of the row numbers there are + & - the show groups of rows. I want to group them with VBA. I want to keep the indenting. Example of current sheet. I want to group the 2's below the 1s and the 1s below the 0. I actually have 4 levels of indents. I have about 300 rows therefore speed is a concern. Row Description indent LevelMore columns 1 Desc 0 2 Desc 1 3 Desc 2 4 Desc 2 5 Desc 1 6 Desc 2 7 Desc 2 8 Desc 2 9 Desc 0 10 Desc 1 11 Desc 1 On Apr 13, 11:54 am, Joel wrote: Hope this helps. You can remove idents by use negaive numbers for identlevel. You will get an error 1004 if you go under 1. If the ident level is two you can one use identlevel -1 (-2 will give the error). Sub Macro1() ' ' Macro1 Macro ' Macro recorded 4/13/2007 by Joel Warburg ' 'Ident text For RowCount = 1 To 10 Range("A" & CStr(RowCount)).InsertIndent RowCount Next RowCount 'read ident level For RowCount = 1 To 10 MsgBox (CStr(Range("A" & CStr(RowCount)).IndentLevel)) Next RowCount End Sub " wrote: I have a worksheet with column B being titles that are indented to outline the list (I even have the indent level a column). I would like to outline this with VBA with a macro, so I can hide and show the details as necessary. Can anyone help me with how to set up the loops to search and determine the first and last rows of the group. My summary row is above. I know how to group and outline rows manually and have recorded it. The issue is I want to be able to automate the process for future versions. I also add and delete rows which causes outlining errors. Example Row Description indent LevelMore columns 1 Desc 1 0 1 Desc 1 1 1 Desc 1 2 1 Desc 1 2 1 Desc 1 1 1 Desc 1 2 1 Desc 1 2 1 Desc 1 2 1 Desc 1 0 1 Desc 1 1 1 Desc |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to Outline based on Indent Level
I provided the code you asked for so in the future you can automatically add
the identing. You basically want to either 1) hide every row with an ident of 2 or more. 2) Or unhide all rows. "Carlg" wrote: Joel, Sorry for the confusion. the example below is what I already have. I want to be able to use the "Outline" ability of Excel to hide an show the subordanate rows. To the left of the row numbers there are + & - the show groups of rows. I want to group them with VBA. I want to keep the indenting. Example of current sheet. I want to group the 2's below the 1s and the 1s below the 0. I actually have 4 levels of indents. I have about 300 rows therefore speed is a concern. Row Description indent LevelMore columns 1 Desc 0 2 Desc 1 3 Desc 2 4 Desc 2 5 Desc 1 6 Desc 2 7 Desc 2 8 Desc 2 9 Desc 0 10 Desc 1 11 Desc 1 On Apr 13, 11:54 am, Joel wrote: Hope this helps. You can remove idents by use negaive numbers for identlevel. You will get an error 1004 if you go under 1. If the ident level is two you can one use identlevel -1 (-2 will give the error). Sub Macro1() ' ' Macro1 Macro ' Macro recorded 4/13/2007 by Joel Warburg ' 'Ident text For RowCount = 1 To 10 Range("A" & CStr(RowCount)).InsertIndent RowCount Next RowCount 'read ident level For RowCount = 1 To 10 MsgBox (CStr(Range("A" & CStr(RowCount)).IndentLevel)) Next RowCount End Sub " wrote: I have a worksheet with column B being titles that are indented to outline the list (I even have the indent level a column). I would like to outline this with VBA with a macro, so I can hide and show the details as necessary. Can anyone help me with how to set up the loops to search and determine the first and last rows of the group. My summary row is above. I know how to group and outline rows manually and have recorded it. The issue is I want to be able to automate the process for future versions. I also add and delete rows which causes outlining errors. Example Row Description indent LevelMore columns 1 Desc 1 0 1 Desc 1 1 1 Desc 1 2 1 Desc 1 2 1 Desc 1 1 1 Desc 1 2 1 Desc 1 2 1 Desc 1 2 1 Desc 1 0 1 Desc 1 1 1 Desc |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to promote/demote Excel rows to new outline group level? | Excel Discussion (Misc queries) | |||
Resetting view when hiding detail in outline level | Excel Discussion (Misc queries) | |||
Test for outline level of cell | Excel Worksheet Functions | |||
In a formula how can I reference the outline level of a row? | Excel Worksheet Functions | |||
How can I query the 'indent' level of text in a cell? | Excel Programming |