Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub Z_perf_grouping()
- Dim start_row
- Dim rownum_columm
- Dim finish_row
- start_row = 18
- rownum_columm = 1
- level_column = 10
- list.Cells(start_row, rownum_columm).Select
- Selection.End(xlDown).Select
- finish_row = Selection.Row
- Selection.End(xlUp).Select
- If finish_row > 65000 Then
- Exit Sub 'При большом количестве позиций - отключаем группировку
- End If
- prev_rownum = 1
- start_range = start_row
- For i = start_row To finish_row + 1
- curr_rownum = list.Cells(i, rownum_columm).Value
- If prev_rownum <> curr_rownum Then
- finish_range = i
- adress = start_range + 1 & ":" & finish_range - 1
- Rows(adress).Select
- Selection.Rows.Group
- 'MsgBox adress
- start_range = finish_range
- End If
- prev_rownum = curr_rownum
- Next i
- level_start_rownum = 0
- For i = start_row To finish_row + 1
- curr_level = list.Cells(i, level_column).Value
- If curr_level = 3 Then
- If level_start_rownum = 0 Then
- level_start_rownum = i
- Else
- 'идём дальше
- End If
- Else
- If level_start_rownum = 0 Then
- 'не то
- Else
- adress = level_start_rownum & ":" & i - 1
- Rows(adress).Select
- Selection.Rows.Group
- 'MsgBox adress
- level_start_rownum = 0
- End If
- End If
- Next i
- 'MsgBox "Done"
- ActiveSheet.Outline.ShowLevels RowLevels:=2
- ActiveSheet.Outline.ShowLevels RowLevels:=1
- list.Cells(start_row, rownum_columm).Select
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement