LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Merged cell auto row height revisited

I seem to hit a deadend in the following topic, but came across another
idea.
http://groups.google.com/group/micro...9 a0b49426a28

What I am trying to do is make a merged cell automatically adjust the
row height if the text is longer than the cell width.
The merged cells are all formatted to wrap text.

Here is what the code looks like:

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

The problem with this code is that it only works when you first select
the cell.
What we have to do is type the text, navigate away and reselect the
cell.

I want it to run it's routine when the enter key is pressed or you
navigate away from the active cell.

How can this code be changed to accomplish this?

Another option would be to have it continuously scan a range or column.
Above row 12, the cells are not merged, so I don't know if this would
be a problem.

 
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
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 Dave Peterson Excel Programming 12 December 16th 06 05:30 PM
Auto row height for merged cells RealmSteel[_2_] Excel Programming 1 December 11th 06 08:47 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 05:46 AM.

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"