一応、提示させていただきます。但し、下記前提です。
◆「AdjustMergedCellHeight」だけです。
◆以下のブロックは、よく理解できないので、そのままです。
' 値を安全に取得
txt = rng.Cells(1, 1).Value
If Len(txt) = 0 Then
' 空の場合は最小高さを設定
rng.rowHeight = 280
Exit Sub
End If
◆提示コード
Private Sub AdjustMergedCellHeight()
Const r列幅最大 As Double = 255
Const r行高最大 As Double = 409
Const r行高省略 As Double = 280
Dim rng As Range
Dim txt As String
Dim lineCount As Long
Dim rowHeight As Double
Dim wb As Workbook, ws As Worksheet
Application.EnableEvents = False
' 対象セル範囲(結合セル)
Set rng = Me.Range(\u0026quot;B10:L10\u0026quot;)
' 値を安全に取得
txt = rng.Cells(1, 1).Value
If Len(txt) = 0 Then
' 空の場合は最小高さを設定
rng.rowHeight = 280
Exit Sub
End If
''別ブックで行の高さを取得
Application.ScreenUpdating = False
With Workbooks.Add
With .Sheets(1).Range(\u0026quot;B1\u0026quot;)
.Value = rng.Value ''値・属性の設定
.Font.Bold = rng.Font.Bold
.Font.Size = rng.Font.Size
.Font.Name = rng.Font.Name
.Font.Bold = rng.Font.Bold
.Font.Italic = rng.Font.Italic
.WrapText = True
.EntireColumn.ColumnWidth = r列幅最大
'.EntireColumn.AutoFit
.EntireRow.rowHeight = r行高最大
.EntireRow.AutoFit
rowHeight = .rowHeight + 5 ''微調整
End With
Application.DisplayAlerts = False
.Close False
Application.DisplayAlerts = True
End With
Application.ScreenUpdating = True
''行の高さを設定
With Range(\u0026quot;B10\u0026quot;)
If rowHeight \u0026lt; r行高省略 Then
.EntireRow.rowHeight = r行高省略
ElseIf rowHeight \u0026lt; r行高最大 Then
.EntireRow.rowHeight = rowHeight
Else
.EntireRow.rowHeight = r行高最大
End If
End With
Application.EnableEvents = True
End Sub