Dim levalmax As Integer
Sub auto_level_exit()
oldrow = 0
linmax = Sheet1.UsedRange.Rows.Count
colonmax = Sheet1.UsedRange.Columns.Count
‘MsgBox "auto_level_exit oldrow is : " & oldrow
i = 100
levalmax = 1
For i = linmax To 1 Step -1
str1 = Sheet1.Cells(i, 1)
str2 = Right(str1, 5)
If str2 = "exit " Or str2 = " exit" Then
oldrow = newrow
newrow = i
For j = i - 1 To 1 Step -1
str3 = Sheet1.Cells(j, 1)
str4 = Left(str3, Len(str1) - 1)
str5 = Right(str4, 4)
If str5 <> " " Then
oldrow = j + 1
j = 0
If oldrow <> newrow Then
Rows(oldrow & ":" & newrow).Select
Selection.Rows.Group
Exit For
End If
End If
Next
‘get number of space to calculate the level
spacelen = Len(str1)
levelnum = spacelen / 4
If levalmax < levelnum Then
levalmax = levelnum
End If
End If
Next
End Sub
Sub auto_level_echo()
oldrow = 0
linmax = Sheet1.UsedRange.Rows.Count
colonmax = Sheet1.UsedRange.Columns.Count
‘MsgBox "oldrow is : " & oldrow
For i = 1 To linmax
str1 = Sheet1.Cells(i, 1)
str2 = Left(str1, 6)
If str2 = " echo" Then
oldrow = newrow
newrow = i
If oldrow <> 0 Then
Rows(oldrow + 1 & ":" & newrow - 2).Select
Selection.Rows.Group
End If
End If
If i = linmax - 7 Then
Rows(newrow + 1 & ":" & i).Select
Selection.Rows.Group
End If
Next
End Sub
Sub auto_nolevel_echo()
oldrow = 0
linmax = Sheet1.UsedRange.Rows.Count
colonmax = Sheet1.UsedRange.Columns.Count
‘MsgBox "oldrow is : " & oldrow
‘rowlevel = Sheet1.Outline.SummaryRow
‘colomnlevel = Sheet1.Outline.SummaryColumn
For i = 1 To levalmax - 1 ‘ linmax
Rows(1 & ":" & linmax).Select
Selection.Rows.Ungroup
Next
levalmax = 0
End Sub
Sub auto_level_config()
Dim i, j As Integer
Dim str1, str2, str3 As String
Dim linemax, colonmax As Integer
linmax = Sheet1.UsedRange.Rows.Count
colonmax = Sheet1.UsedRange.Columns.Count
‘MsgBox "line is: " & linmax & "column is " & colonmax
oldrow = 1
newrow = 5
auto_level_echo
auto_level_exit
End Sub
Sub nogroup()
‘
‘ nogroup Macro
‘
Rows("1742:1747").Select
Selection.Copy
Application.CutCopyMode = False
Selection.Rows.Ungroup
End Sub