Maybe try this? Note you will have to change the range to suit yourself.

Sub AutoWrapAndAutofitMergedCells()
    Dim rng As Range
    Dim cell As Range
    ' Set the range you want to process. For example, the entire used range of Sheet1.
    ' Adjust as needed.
    Set rng = ThisWorkbook.Sheets("Sheet1").UsedRange
    ' Loop through each cell in the range
    For Each cell In rng
        ' Check if the cell is part of a merged area
        If cell.MergeCells Then
            ' Enable text wrapping
            cell.WrapText = True
            ' Autofit the row height of the merged area
            cell.MergeArea.Rows.AutoFit
        End If
    Next cell
    ' Clean up  Set rng = Nothing
    Set cell = Nothing
End Sub