ctownsen80
asked on
Auto Outline Dataset in Excel
I am wanting to create an Auto outline macro in Excel for a data set. See the dataset in Sheet1 of the attached file. I want the code to be able to got through that dataset and each time it "reads" the word "Total", group the rows above it. An example of the dataset is in Sheet1 and an example of the desired output is in Sheet2.
Let know if any addtional clarification is needed.
Any takers?
Thanks,
EE-Example.xlsm
Let know if any addtional clarification is needed.
Any takers?
Thanks,
EE-Example.xlsm
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you have formulas then you can use the auto outline feature. Excel uses the formula's to create the auto outline. That said I don't believe that an auto outline is going to work for your purposes unless you have formula's built into your spreadsheet.
If you are going to use just text data/totals, then you will need to just use standard vba code.
I've tossed together this VBA code block that should do what you want. It is designed to start grouping on row eight.
If you are going to use just text data/totals, then you will need to just use standard vba code.
I've tossed together this VBA code block that should do what you want. It is designed to start grouping on row eight.
Sub Total()
ptr = 8
Nextnt:
nt = Cells.Find(What:="Total", After:=Cells(ptr, 1), LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Row
If nt < ptr Then GoTo Done
Range(Cells(ptr, 1), Cells(nt - 1, 1)).Select
Selection.Rows.Group
ptr = nt + 1
GoTo Nextnt
Done:
End Sub
ASKER
Worked Like a Charm! Thank you very much.
Thomas
Open in new window