ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to set AutoFit property in Excel for merged cells (https://www.excelbanter.com/excel-programming/299638-how-set-autofit-property-excel-merged-cells.html)

Roman Malakhovetskyy

How to set AutoFit property in Excel for merged cells
 
Using JScript.
I have merged some amount of cells and type some text in.
How can I to set autofit for text in merged cells

Roger Whitehead[_4_]

How to set AutoFit property in Excel for merged cells
 
So far as I'm aware, Autofit does not work for merged cells (Excel 2002)


--
Roger
Shaftesbury (UK)


"Roman Malakhovetskyy" wrote in
message ...
Using JScript.
I have merged some amount of cells and type some text in.
How can I to set autofit for text in merged cells




Tom Ogilvy

How to set AutoFit property in Excel for merged cells
 
Merged cells done support Autofit.

You might pursue some code like this posted by Jim Rech:

Jim Rech

Sub AutoFitMergedCellRowHeight()
Dim CurrentRowHeight As Single, MergedCellRgWidth As Single
Dim CurrCell As Range
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
For Each CurrCell In Selection
MergedCellRgWidth = CurrCell.ColumnWidth + _
MergedCellRgWidth
Next
.MergeCells = False
.Cells(1).ColumnWidth = MergedCellRgWidth
.EntireRow.AutoFit
PossNewRowHeight = .RowHeight
.Cells(1).ColumnWidth = ActiveCellWidth
.MergeCells = True
.RowHeight = IIf(CurrentRowHeight PossNewRowHeight, _
CurrentRowHeight, PossNewRowHeight)
End If
End With
End If
End Sub

--
Regards,
Tom Ogilvy

"Roman Malakhovetskyy" wrote in
message ...
Using JScript.
I have merged some amount of cells and type some text in.
How can I to set autofit for text in merged cells





All times are GMT +1. The time now is 05:35 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com