Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default RowHeight automatically change when user does ALT+ENTER for linefe

Merged cells won't autofit for row height.

here is some code written by Jim Rech

which sizes the rowheight for a merged cell. Perhaps you can incorporate a
similar approach in your code.

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

"GaryZ" wrote in message
...
Hi,

I have a VFP program that generates a spreadsheet.

In the generated spreadsheet, I have a cell merged across columns A

through
D used for a multiline comment.

For the cell, I have WordWrap = True. However, when the user puts a

linefeed
into the comment via ALT+ENTER, the RowHeight does not adjust and only one
line of the comment is visible.

Is there any way, while generating the spreadsheet, to mark the cell with
automatically adjustable rowheight?

Here is the source for the cell definition.

m_row = m_row + 1
strrow = ALLT(STR(m_row))
.Range("A"+strrow+":D"+strrow).mergecells = True
With .Range("A"+strrow)
.WrapText = True
.HorizontalAlignment = xlLeft
EndWith



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
Is RowHeight=0 the same as Hidden Michelle Excel Discussion (Misc queries) 4 February 22nd 10 02:02 PM
In Excel why does the date I enter automatically change by 1 day? skoag Excel Worksheet Functions 1 May 8th 06 09:48 PM
In Excel why does the date I enter automatically change by 1 day? skoag Excel Worksheet Functions 0 May 8th 06 09:38 PM
Automatically changing the rowheight Ajit[_4_] Excel Programming 2 February 26th 04 03:01 PM
autofit rowheight after auto change line RC[_3_] Excel Programming 1 January 16th 04 12:31 PM


All times are GMT +1. The time now is 08:32 PM.

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"