Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I got the following code from elsewhere on the site and I am not real
familiar with Macros. The code runs without any errors, but it does nothing to the merged cells that I want to expand to show all the characters in them. Can someone give me a Macro primer? Sub AutoFitMergedCellRowHeight() Dim CurrentRowHeight As Single, MergedCellRgWidth As Single Dim CurrCell As Range, RangeWidth As Single Dim ActiveCellWidth As Single, PossNewRowHeight As Single If ActiveCell.MergeCells Then With ActiveCell.MergeArea If .Rows.Count = 1 And .WrapText = True Then Application.ScreenUpdating = False CurrentRowHeight = .RowHeight ActiveCellWidth = ActiveCell.ColumnWidth RangeWidth = .Width For Each CurrCell In Selection MergedCellRgWidth = CurrCell.ColumnWidth + MergedCellRgWidth Next .MergeCells = False .Cells(1).ColumnWidth = MergedCellRgWidth While .Cells(1).Width < RangeWidth .Cells(1).ColumnWidth = .Cells(1).ColumnWidth + 0.5 Wend .Cells(1).ColumnWidth = .Cells(1).ColumnWidth - 0.5 .EntireRow.AutoFit PossNewRowHeight = .RowHeight .Cells(1).ColumnWidth = ActiveCellWidth .MergeCells = True .RowHeight = IIf(CurrentRowHeight PossNewRowHeight, _ CurrentRowHeight, PossNewRowHeight) End If End With End If -- Thanks You all are teaching me so much |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Merged Cells Autofit Macro Help | Excel Programming | |||
Autofit Merged cell Code is changing the format of my merged cells | Excel Discussion (Misc queries) | |||
Need macro to autofit height for merged cells | Excel Programming | |||
Code for autofit/merged cells doesn't work | Excel Programming | |||
Merged Cells Autofit - code amendment | Excel Programming |