Una famiglia di software per fogli di calcolo Microsoft con strumenti per l'analisi, la creazione di grafici e la comunicazione dei dati.
La risposta è stata tradotta automaticamente. Di conseguenza, potrebbero esserci errori grammaticali o parole insolite.
Ciao, zeroGianni
Grazie per aver utilizzato i prodotti Microsoft e per averli pubblicati nella community.
Non esiste una funzione simile per le celle unite; è possibile fare clic sulle singole celle, ad esempio facendo doppio clic sulle righe, ma questo non funziona per le celle unite.
Esistono due opzioni: una è quella di selezionare le celle unite e poi, nell'allineamento, scegliere l'avanzamento automatico delle righe, ma questo non soddisfa necessariamente le vostre esigenze.
La seconda è un codice VBA che si adatta il più possibile all'altezza delle righe, con l'effetto mostrato di seguito:
Tieni premuto Alt+F11 per aprire l'editor VBA.
Fai doppio clic sulla cartella di lavoro e inserisci il codice nella finestra che si apre.
Chiudi tutte le finestre.
Tieni premuto ALT+F8 per aprire il riquadro Esegui, quindi seleziona AutoFitMergedCellRowHeight e fai clic su Esegui
Codice:
Sub AutoFitMergedCellRowHeight()
Dim CurrentRowHeight As Single
Dim MergedCellRgWidth As Single
Dim CurrCell As Range
Dim ActiveCellWidth As Single
Dim PossNewRowHeight As Single
Dim StartCell As Range
Dim i As Integer
On Error Resume Next
' Set the range to be the used range of the active sheet
Set StartCell = ActiveSheet.UsedRange
' Loop through each cell in the range
For Each CurrCell In StartCell
If CurrCell.MergeCells Then
Application.ScreenUpdating = False
With CurrCell.MergeArea
.WrapText = True
' Store the current row height
CurrentRowHeight = .Rows(1).RowHeight
' Calculate the width of the merged cell range
MergedCellRgWidth = 0
For i = 1 To .Columns.Count
MergedCellRgWidth = MergedCellRgWidth + .Columns(i).ColumnWidth
Next i
' Store the active cell width
ActiveCellWidth = CurrCell.ColumnWidth
' Set the column width to the width of the merged cell range
CurrCell.ColumnWidth = MergedCellRgWidth
' Autofit the row height
.Rows.AutoFit
' Store the new row height
PossNewRowHeight = .Rows(1).RowHeight
' Reset the column width
CurrCell.ColumnWidth = ActiveCellWidth
' Set the row height to the larger of the current and new row heights
If CurrentRowHeight > PossNewRowHeight Then
.RowHeight = CurrentRowHeight
Else
.RowHeight = PossNewRowHeight
End If
End With
Application.ScreenUpdating = True
End If
Next
End Sub
Aiden.C - MSFT |Specialista del supporto della community Microsoft
nella parte superiore del foglio di lavoro per selezionare tutte le colonne e le righe.