Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / March 2008

Tip: Looking for answers? Try searching our database.

WrapText Property

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Howard Kaikow - 16 Mar 2008 18:03 GMT
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?

Signature

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

Peter T - 16 Mar 2008 19:41 GMT
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

> Excel's Help states:
>
[quoted text clipped - 11 lines]
>
> Am I doing something wrong?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.