Excel adjust height of merged cells automatically

前端 未结 3 511
礼貌的吻别
礼貌的吻别 2021-01-03 16:45

I have a little problem in excel. I not experienced with excel macros and would be grateful for some help. I am trying to find a macro which ajustes the height of a merged c

3条回答
  •  清酒与你
    2021-01-03 17:45

    Something like:

    Dim h, rng As Range
    Set rng = Selection
    
    With rng
        .UnMerge
        .Cells(1).EntireRow.AutoFit
        h = .Cells(1).RowHeight
        .Merge
        .EntireRow.AutoFit
        With .Cells(1).MergeArea
            .Cells(.Cells.Count).RowHeight = _
               .Cells(.Cells.Count).RowHeight + (h - .Height)
        End With
    End With
    

提交回复
热议问题