Esta es la macro para ajustar las celdas
Sub centrar()
'Por.Dante Amor
Application.ScreenUpdating = False
i = 27
Do While Cells(i, "O") <> ""
ajustarfila Range("O" & i & ":V" & i), Range("AD" & i & ":AM" & i)
i = i + 1
Loop
ruta = ThisWorkbook.Path & "\"
nombre = Left(ThisWorkbook.Name, InStrRev(ThisWorkbook.Name, ".") - 1)
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=ruta & nombre & ".pdf" _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False
Application.ScreenUpdating = True
MsgBox "Celdas ajustadas y PDF generado", vbInformation
End Sub
Sub ajustarfila(rngRango As Range, rngRango2 As Range)
'Por.Dante Amor
For n = 1 To rngRango.Columns.Count
sngAnchoTotal = sngAnchoTotal + rngRango.Cells(1, n).ColumnWidth
Next n
For n = 1 To rngRango2.Columns.Count
sngAnchoTotal2 = sngAnchoTotal2 + rngRango2.Cells(1, n).ColumnWidth
Next n
With rngRango.Cells(1, 1)
sngAnchoCelda = .ColumnWidth
.MergeCells = False
.ColumnWidth = sngAnchoTotal
rngRango.Parent.Rows(rngRango.Row).AutoFit
sngAlto = .RowHeight
End With
With rngRango2.Cells(1, 1)
sngAnchoCelda2 = .ColumnWidth
.MergeCells = False
.ColumnWidth = sngAnchoTotal2
rngRango2.Parent.Rows(rngRango2.Row).AutoFit
sngAlto2 = .RowHeight
End With
If sngAlto > sngAlto2 Then sngAlto3 = sngAlto Else sngAlto3 = sngAlto2
With rngRango
.Merge
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.IndentLevel = 1
.Columns(1).EntireColumn.ColumnWidth = sngAnchoCelda
.Columns(1).RowHeight = sngAlto3
End With
With rngRango2
.Merge
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.IndentLevel = 1
.Columns(1).EntireColumn.ColumnWidth = sngAnchoCelda2
'.Columns(1).RowHeight = sngAlto3
End With
End Sub
Saludos.Dante Amor
No olvides valorar la respuesta.