Всем привет!
Вопрос решил своими силами, но прошу помощи в оптимизации кода.
Думается, что оно может работать быстрее.
'find last not empty cell in "B"
kLastRow = Cells(Rows.Count, "B").End(xlUp).Row
'Up from last not empty cell to row 2
For k = kLastRow To 2 Step -1
'if cells in B have "*+*" - add 1 rows
If Cells(k, "B") Like "*+*" Then
Rows(k).Select
Selection.Copy
Rows(k).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
End If
'if cells in B have "*+*+*" - 2 rows
If Cells(k, "B") Like "*+*+*" Then
Rows(k).Select
Selection.Copy
Rows(k + 1).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
End If
'if cells in B have "*+*+*+*" - 3 rows
If Cells(k, "B") Like "*+*+*+*" Then
Rows(k).Select
Selection.Copy
Rows(k + 2).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
End If
Next k
' Delete "+..+" in Column "B"
Dim n1 As Long, n2 As Long
'find last not empty cell in "B"
jLastRow = Cells(Rows.Count, "B").End(xlUp).Row
'Up from last not empty cell to row 2
For j = jLastRow To 2 Step -1
n1 = InStr(1, Cells(j, "B"), "+")
n2 = InStr(n1 + 1, Cells(j, "B"), "+")
n3 = InStr(n1 + 2, Cells(j, "B"), "+")
'if cells in Column "B" have "*+*+*+*" - put values between "+" in each rows and delete "+"
If Cells(j, "B") Like "*+*+*+*" Then
Cells(j, "B") = Right(Cells(j, "B"), n1 - 1)
Cells(j - 1, "B") = Mid(Cells(j - 1, "B"), n2 + 1, n3 - n1 - 1)
Cells(j - 2, "B") = Mid(Cells(j - 2, "B"), n1 + 1, n2 - n1 - 1)
Cells(j - 3, "B") = Left(Cells(j - 3, "B"), n1 - 1)
End If
'if cells in Column "B" have "*+*+*" - put values between "+" in each rows and delete "+"
If Cells(j, "B") Like "*+*+*" Then
Cells(j, "B") = Right(Cells(j, "B"), n1 - 1)
Cells(j - 1, "B") = Mid(Cells(j - 1, "B"), n1 + 1, n2 - n1 - 1)
Cells(j - 2, "B") = Left(Cells(j - 2, "B"), n1 - 1)
End If
'if cells in Column "B" have "*+*" - put values between "+" in each rows and delete "+"
If Cells(j, "B") Like "*+*" Then
Cells(j, "B") = Right(Cells(j, "B"), n1 - 1)
Cells(j - 1, "B") = Left(Cells(j - 1, "B"), n1 - 1)
End If
Next j