Pielāgojiet apvienoto šūnu rindu augstumu, izmantojot Microsoft Excel VBA

Anonim

Jautājums:
Apvienotajām šūnām pēc rindas pārtraukuma nav pareizs augstums. Kā es varu to labot?

Atbilde:
Standarta modulī ievietojiet šādu kodu.

 Sub AutoFitMergedCellRowHeight () Dim CurrentRowHeight kā Single, MergedCellRgWidth kā ​​Single Dim CurrCell As Range Dim ActiveCellWidth as Single, PossNewRowHeight As Single Ja ActiveCell.MergeCells Tad ar ActiveCell.MergeArea Ja .Rows.CountTe = 1Ut. False CurrentRowHeight = .RowHeight ActiveCellWidth = ActiveCell.ColumnWidth katrai atlasītajai CurrCell MergedCellRgWidth = CurrCell.ColumnWidth + MergedCellRgWidth Next .MergeCells = False .Cells (1) .ColumnWidth = MergedCellRowRight ColumnWidth = ActiveCellWidth .MergeCells = True .RowHeight = IIf (CurrentRowHeight> PossNewRowHeight, _ CurrentRowHeight, PossNewRowHeight) Beigas Ja beigas ar Beigu Ja lietojumprogramma.ScreenUpdating = True End Sub