<= UBound(tmp_array)
tmp_c = tmp_array(j)
i = 2
Select Case tmp_c
Case Is < 3:
nr = sh.UsedRange.Rows.Count
Do While i <= nr
If i = 2 Then
ini_str = sh.Cells(i, tmp_c)
With sh.Rows(i + 1)
.Insert Shift:=xlDown
sh.Cells(i + 1, tmp_c + 2) = sh.Cells(i, tmp_c + 2)
sh.Cells(i + 1, tmp_c + 3) = sh.Cells(i, tmp_c + 3)
sh.Cells(i + 1, tmp_c + 4) = sh.Cells(i, tmp_c + 4)
sh.Range(Cells(i, tmp_c + 2), Cells(i, tmp_c + 4)).Clear
End With
nr = nr + 1
i = i + 1
Else
tmp_str = sh.Cells(i, tmp_c)
If tmp_str = ini_str Then
sh.Range(Cells(i, tmp_c), Cells(i, tmp_c + 1)).Clear
Else
ini_str = tmp_str
With sh.Rows(i + 1)
.Insert Shift:=xlDown
sh.Cells(i + 1, tmp_c + 2) = sh.Cells(i, tmp_c + 2)
sh.Cells(i + 1, tmp_c + 3) = sh.Cells(i, tmp_c + 3)
sh.Cells(i + 1, tmp_c + 4) = sh.Cells(i, tmp_c + 4)
sh.Range(Cells(i, tmp_c + 2), Cells(i, tmp_c + 4)).Clear
End With
nr = nr + 1
i = i + 1
End If
End If
i = i + 1
Loop
Case Else:
nr = sh.UsedRange.Rows.Count
For k = 2 To nr
If sh.Cells(k, tmp_c - 1) <> "" Then
i = k + 1
With sh.Cells(i, tmp_c)
ini_str = .Value
If .Offset(1, 0) = "" Then
tmp_end = i
Else
tmp_end = .End(xlDown).Row
End If
End With
Do While i <= tmp_end
tmp_str = sh.Cells(i, tmp_c)
If tmp_str = ini_str And i = k + 1 Then
With sh.Rows(i + 1)
.Insert Shift:=xlDown
sh.Cells(i + 1, tmp_c + 1) = sh.Cells(i, tmp_c + 1)
sh.Cells(i + 1, tmp_c + 2) = sh.Cells(i, tmp_c + 2)
sh.Range(Cells(i, tmp_c + 1), Cells(i, tmp_c + 2)).Clear
End With
i = i + 1
nr = nr + 1
tmp_end = tmp_end + 1
Else
If tmp_str = ini_str Then
sh.Cells(i, tmp_c).Clear
Else
If tmp_str <> "" Then
ini_str = tmp_str
With sh.Rows(i + 1)
.Insert Shift:=xlDown
sh.Cells(i + 1, tmp_c + 1) = sh.Cells(i, tmp_c + 1)
sh.Cells(i + 1, tmp_c + 2) = sh.Cells(i, tmp_c + 2)
sh.Range(Cells(i, tmp_c + 1), Cells(i, tmp_c + 2)).Clear
End With
nr = nr + 1
i = i + 1
tmp_end = tmp_end + 1
End If
End If
End If
i = i + 1
Loop
k = i - 1
End If
Next
End Select
j = j + 1
Loop
End Sub
Sub group()
Dim sht As Worksheet
Dim row_start%, row_end%
Dim target_column
Set sht = Sheets("structure")
row_start = 2
target_column = "D"
' row_end = sht.Cells(1048576, target_column).End(xlUp).Row + 1
row_end = sht.UsedRange.Rows.Count
sht.Cells.ClearOutline
Dim i
Dim refer_row%
i = row_start
refer_row = row_start
Do While i <= row_end
If Cells(i, 1) <> "" Then
With Range(Cells(i, 1), Cells(i, 5))
.Interior.Color = RGB(208, 206, 206)
.Font.Color = RGB(0, 0, 0)
.Font.Bold = True
With .Borders(xlEdgeTop)
.LineStyle = xlDash
.Color = RGB(166, 166, 166)
End With
With .Borders(xlEdgeBottom)
.LineStyle = xlDash
.Color = RGB(166, 166, 166)
End With
End With
End If
If Cells(i, 3)