LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Auto row height for merged cells

Jim,

I'm obviously doing something wrong.

I just created a new workbook and inserted the following code into
worksheet:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Rows.AutoFit
End Sub

I then merged 3 columns (B, C & D) in row 3, formatted them for left
justification and Wrap text.
I copy and pasted these cells for another 10 rows.

I verified the formatting for all the merged cells is Wrap Text.

I typed into one of the cells a line longer than the merged cell width
and nothing happened.

My version os Excell 2003 if that matters.

I did notice with the code from the link I provided in my first post,
the cell will auto adjust if I navigate back to it and then away.
All I have to do is select it and then select another cell. The row
will automatically adjust.
I'd like it to auto adjust as a soon as I navigate away.

Here is what the code looks like right now:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
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

Thanks,
Rich


On Dec 11, 1:48 pm, Jim Jackson
wrote:
When I formatted some cells as "Wrap Text" and typed a sentence in one, made
sure only one line of text was showing and clicked "Enter", the cells resized
to show the complete text.

Are your cells already formatted to allow Wrapping of Text?

--
Best wishes,

Jim


text -- Hide quoted text -- Show quoted text -

 
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
Auto Row Height with Wrapped Text in Merged Cells Problem Rick Cl. Excel Discussion (Misc queries) 3 June 3rd 10 11:21 PM
How to enable auto height with merged cells? lgreggs Excel Worksheet Functions 0 March 18th 10 03:29 PM
Auto Row Height in Merged Cells with pre exisiting text gwinder Excel Worksheet Functions 2 December 14th 06 05:31 PM
Solution To Auto Height For Merged Cells JoJo Excel Programming 0 August 16th 06 10:58 PM
Auto Row Height for Merged Cells Jamie Excel Programming 13 July 1st 05 12:55 AM


All times are GMT +1. The time now is 12:26 PM.

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

About Us

"It's about Microsoft Excel"