Sub TH()
Application.ScreenUpdating = False
Call abc
Call Merge_abc
Application.ScreenUpdating = True
End Sub
Sub abc()
Dim i, LR, Cll
LR = Sheets(1).Cells(Rows.Count, 6).End(3).Rows
i = 4
[B4:B51].UnMerge
On Error Resume Next
With Sheets(1)
For Each Cll In Sheets(2).Range("A2", Sheets(2).Cells(Rows.Count, 1).End(3))
.Cells(i, 2) = Cll.Value
i = i + 3
Next
End With
With Sheets(1).Range("B4:B" & Range("f" & Rows.Count).End(3).Row)
.SpecialCells(4).FormulaR1C1 = "=R[-1]C"
.Value = .Value
End With
For i = LR To 4
If Cells(i, 2) = Cells(i - 1, 2) Then
Range(Cells(i, 2), Cells(i - 1, 2)).Merge
End If
Next i
End Sub
Sub Merge_abc()
Dim LR, LR2 As Long, i As Long
LR = Cells(Rows.Count, "B").End(xlUp).Row
i = 4
Do While i < LR
LR2 = 1
Do While Cells(i, 2) = Cells(i + LR2, 2)
LR2 = LR2 + 1
Loop
If LR2 > 1 Then
Cells(i + 1, 2).Resize(LR2 - 1).ClearContents
Cells(i, 2).Resize(LR2).Merge
Cells(i, 2).VerticalAlignment = xlCenter
End If
i = i + LR2
Loop
End Sub