Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 269
Default WrapText Property

Excel's Help states:

"Microsoft Excel will change the row height of the range, if necessary, to
accommodate the text in the range."

Using the following, the row height does not change:
With rng
.MergeCells = True
.Value = str ' Some long string that should have to wrap
.WrapText = True
End With

Does not matter whether Value is set before/after WrapText.

Am I doing something wrong?




--
http://www.standards.com/; See Howard Kaikow's web site.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default WrapText Property

Text in merged cells does not make the row height autosize/fit, even with
WrapText.

How best to fix will depend on how much you know about 'required' heights of
other cells in the row. In the simplest scenario start by setting the row's
height to default, and some/all of this

' trap original height
rng(1).MergeArea.MergeCells = False
rng.HorizontalAlignment = xlCenterAcrossSelection
rng(1).value = sLongText
rng.WrapText = True
' might need to autofit the row here
Ht = rng(1).Height
if origHeight Ht then Ht = origHeight
rng.HorizontalAlignment = xlLeft
rng(1).EntireRow.RowHeight = Ht ' if mergearea is only one row

Of course simply doing the above might mess up larger heights in other
merged cells, so how much you'll need to check will depend on what you've
got.

From memory a macro by Jim Rech is often recommended to autofit merged cells
(search this group)

Regards,
Peter T


"Howard Kaikow" wrote in message
...
Excel's Help states:

"Microsoft Excel will change the row height of the range, if necessary, to
accommodate the text in the range."

Using the following, the row height does not change:
With rng
.MergeCells = True
.Value = str ' Some long string that should have to wrap
.WrapText = True
End With

Does not matter whether Value is set before/after WrapText.

Am I doing something wrong?




--
http://www.standards.com/; See Howard Kaikow's web site.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 269
Default WrapText Property

"Bob Phillips" wrote in message
...
Is the range more than one cell? That could be the problem.


Help states that the property applies to a RangeCollection, which is:

"Represents a cell, a row, a column, a selection of cells containing one or
more contiguous blocks of cells, or a 3-D range."

I have tried both Select and Activate on the range, still no height
adjustment,


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
WrapText Property Bob Phillips Excel Programming 0 March 16th 08 05:18 PM
Remove WrapText Alex St-Pierre Excel Programming 9 March 16th 07 06:08 PM
wraptext is not updating when using references to another cell Jurry Excel Programming 7 April 23rd 04 04:23 PM
Convert from WrapText Stuart[_5_] Excel Programming 8 April 20th 04 10:23 AM
Convert from WrapText scoobydeux[_2_] Excel Programming 0 April 18th 04 03:32 PM


All times are GMT +1. The time now is 07:58 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"