Excel_User18
New Member
- Joined
- Sep 4, 2018
- Messages
- 4
I am working on an Excel worksheet based on a MS Project file, and I am trying to write a macro that can group my rows by the WBS number in column A. I am trying to do this by using the formula below. Here is my attempt so far. While the input box does appear, nothing is grouped. Any help would be greatly appreciated!
Sub Group_1()
Dim Rng As Range
Dim WorkRng As Range
Rows.ClearOutline
On Error Resume Next
xTitleId = "Grouping"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
For Each Rng In WorkRng
Rng.EntireRow.OutlineLevel = Rng.Formula = "=LEN(A2)-LEN(SUBSTITUTE(A2,""."",""""))+1"
Next
With ActiveSheet.Outline
.AutomaticStyles = False
.SummaryRow = xlAbove
.SummaryColumn = xlRight
End With
End Sub
Sub Group_1()
Dim Rng As Range
Dim WorkRng As Range
Rows.ClearOutline
On Error Resume Next
xTitleId = "Grouping"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
For Each Rng In WorkRng
Rng.EntireRow.OutlineLevel = Rng.Formula = "=LEN(A2)-LEN(SUBSTITUTE(A2,""."",""""))+1"
Next
With ActiveSheet.Outline
.AutomaticStyles = False
.SummaryRow = xlAbove
.SummaryColumn = xlRight
End With
End Sub