Также вы можете попробовать:
Option Explicit
Sub X()
Dim LR As Long, i As Long, j As Long
Dim rngName As String
With Worksheets("Sheet1")
LR = .Cells(.Rows.Count, "B").End(xlUp).Row
For j = 1 To LR
If .Cells(j, 1).Value <> "" And Cells(j, 2).Value <> "" Then
rngName = .Cells(j, 1).Value
.Cells(j, 2).Select
Do Until IsEmpty(ActiveCell)
If ActiveCell.Offset(, -1).Value <> "" And ActiveCell.Offset(1, -1).Value = "" Then
ActiveCell.Offset(1, -1).Value = ActiveCell.Value
ActiveCell.Clear
ElseIf ActiveCell.Offset(, -1).Value <> "" And ActiveCell.Offset(1, -1).Value <> "" Then
ActiveCell.Offset(1, 1).EntireRow.Resize(2).Insert Shift:=xlDown
ActiveCell.Offset(1, -1).Value = ActiveCell.Value
ActiveCell.Offset(2, -1) = rngName
ActiveCell.Clear
End If
ActiveCell.Offset(1, 0).Select
Loop
ActiveCell.Offset(1, -1) = rngName
End If
Next j
End With
End Sub