T
Toolman045
Hello: This has two (2) questions:
The first and annoying question is: I have the following macro tha
was built to group items with a + symbol in front. It works grea
except that it is always looking for the original workbook it wa
created in. I opened the original workbook and copied then paste i
another workbook. If I move the original workbook the macro fails i
the file I pasted the macro. It probably is something relatively eas
that I am missing.
2nd: I added a macro that will collapse the groups after my workshee
is updated. It does not recognize the coding on the bottom.
Any help with both these problems will greatly be appreciated. Here i
my code:
Sub GroupData()
Dim wb As Workbook, ws As Worksheet
Dim cel As Range, GroupStart As Range, FirstCel As Boolean
Set wb = ActiveWorkbook
For Each ws In wb.Worksheets
If ws.Name = "52_Weeks" Or ws.Name = "13_Weeks" Or ws.Name = "YTD
Then
ws.Activate
ws.Cells.ClearOutline
For Each cel In ws.Range("A1", ws.Range("A65535").End(xlUp).Offset(1
0))
If Left(cel, 1) = "+" And FirstCel = False Then
Set GroupStart = cel
FirstCel = True
End If
If Left(cel, 1) <> "+" And FirstCel = True Then
ws.Range(GroupStart, cel.Offset(-1, 0)).Select
Selection.Rows.Group
FirstCel = False
End If
If cel.Address = ws.Range("A65535").End(xlUp).Offset(1, 0) Then
ws.Range(GroupStart, cel.Offset(-1, 0)).Select
Selection.Rows.Group
FirstCel = False
End If
Next cel
End If
Next ws
Sheets("YTD").Select
ActiveSheet.Outline.ShowLevels RowLevels:=1
Range("A1").Select
Sheets("52_Weeks").Select
ActiveSheet.Outline.ShowLevels RowLevels:=1
Range("A1").Select
Sheets("13_Weeks").Select
ActiveSheet.Outline.ShowLevels RowLevels:=1
Range("A1").Select
End Sub
Again, thanks for your help.
Stev
The first and annoying question is: I have the following macro tha
was built to group items with a + symbol in front. It works grea
except that it is always looking for the original workbook it wa
created in. I opened the original workbook and copied then paste i
another workbook. If I move the original workbook the macro fails i
the file I pasted the macro. It probably is something relatively eas
that I am missing.
2nd: I added a macro that will collapse the groups after my workshee
is updated. It does not recognize the coding on the bottom.
Any help with both these problems will greatly be appreciated. Here i
my code:
Sub GroupData()
Dim wb As Workbook, ws As Worksheet
Dim cel As Range, GroupStart As Range, FirstCel As Boolean
Set wb = ActiveWorkbook
For Each ws In wb.Worksheets
If ws.Name = "52_Weeks" Or ws.Name = "13_Weeks" Or ws.Name = "YTD
Then
ws.Activate
ws.Cells.ClearOutline
For Each cel In ws.Range("A1", ws.Range("A65535").End(xlUp).Offset(1
0))
If Left(cel, 1) = "+" And FirstCel = False Then
Set GroupStart = cel
FirstCel = True
End If
If Left(cel, 1) <> "+" And FirstCel = True Then
ws.Range(GroupStart, cel.Offset(-1, 0)).Select
Selection.Rows.Group
FirstCel = False
End If
If cel.Address = ws.Range("A65535").End(xlUp).Offset(1, 0) Then
ws.Range(GroupStart, cel.Offset(-1, 0)).Select
Selection.Rows.Group
FirstCel = False
End If
Next cel
End If
Next ws
Sheets("YTD").Select
ActiveSheet.Outline.ShowLevels RowLevels:=1
Range("A1").Select
Sheets("52_Weeks").Select
ActiveSheet.Outline.ShowLevels RowLevels:=1
Range("A1").Select
Sheets("13_Weeks").Select
ActiveSheet.Outline.ShowLevels RowLevels:=1
Range("A1").Select
End Sub
Again, thanks for your help.
Stev