79085079

Date: 2024-10-14 07:23:21
Score: 1
Natty:
Report link

Thank you very much for the answer and solution. I followed the answer and changed some parameters and it was as expected for the results.

Option Explicit
Sub Demo()
Dim objDic As Object, rngData As Range
Dim i As Long, sKey, c As Range, arrData
Set objDic = CreateObject("scripting.dictionary")
Set rngData = Range("C1").CurrentRegion
' load data into an array
arrData = rngData.Value
For i = LBound(arrData) To UBound(arrData)
    sKey = arrData(i, 3)
    ' get merged range with Dict object
    If objDic.exists(sKey) Then
        Set objDic(sKey) = Union(objDic(sKey), Cells(i, 8))
    Else
        Set objDic(sKey) = Cells(i, 8)
    End If
Next i
' merge range on Col B
Application.DisplayAlerts = False
For Each sKey In objDic.Keys
    Set c = objDic(sKey)
    If c.Cells.Count > 1 Then
        c.Merge
    End If
Next
Application.DisplayAlerts = True
End Sub

Reasons:
  • Blacklisted phrase (0.5): Thank you
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Cahyo Permadi