#1   Report Post  
Posted to microsoft.public.excel.misc
A A is offline
external usenet poster
 
Posts: 37
Default row heights

I have spreadsheets which have merged cells to insert comments on variances.
The format of the merged cells is set to wrap text if the text string is
longer than the cell. How can I format the row/cell so that if the text does
wrap to more than one line, then the row automatically resizes so that the
entire text string is visible.

Thanks for your help
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default row heights

Long audible sigh here.................

One more victim of "merged cells".

Wrap Text works fine on merged cells, but Autofit does not work.

You need VBA event code or a macro to do that.

Here is event code from Greg Wilson.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim NewRwHt As Single
Dim cWdth As Single, MrgeWdth As Single
Dim c As Range, cc As Range
Dim ma As Range

With Target
If .MergeCells And .WrapText Then
Set c = Target.Cells(1, 1)
cWdth = c.ColumnWidth
Set ma = c.MergeArea
For Each cc In ma.Cells
MrgeWdth = MrgeWdth + cc.ColumnWidth
Next
Application.ScreenUpdating = False
ma.MergeCells = False
c.ColumnWidth = MrgeWdth
c.EntireRow.AutoFit
NewRwHt = c.RowHeight
c.ColumnWidth = cWdth
ma.MergeCells = True
ma.RowHeight = NewRwHt
cWdth = 0: MrgeWdth = 0
Application.ScreenUpdating = True
End If
End With
End Sub

This is event code. Right-click on the sheet tab and "View Code".

Copy/paste the above into that sheet module.


Gord Dibben MS Excel MVP

On Wed, 28 Feb 2007 05:50:35 -0800, A wrote:

I have spreadsheets which have merged cells to insert comments on variances.
The format of the merged cells is set to wrap text if the text string is
longer than the cell. How can I format the row/cell so that if the text does
wrap to more than one line, then the row automatically resizes so that the
entire text string is visible.

Thanks for your help


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel: copy grid, widths & heights down page: heights wrong! why? K Excel Discussion (Misc queries) 1 June 24th 06 03:06 AM
Heights Dig Excel Discussion (Misc queries) 2 April 24th 06 08:54 PM
How do I keep row heights while sorting? Ryan8605 Excel Discussion (Misc queries) 1 January 29th 05 12:54 AM
Can I have different cell heights in the same row Liz Excel Discussion (Misc queries) 3 January 29th 05 12:33 AM
can the same row, have different heights in different columns ? toni Excel Discussion (Misc queries) 2 January 20th 05 03:56 PM


All times are GMT +1. The time now is 07:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"