How to determine whether text in cell needs to be wrapped?

J

Joe HM

Hello -

I want to determine whether a string will fit into a column or now
(i.e. whether it needs to be wrapped or not). I looked at the WrapText
property but that is only set when the cell is actually wrapped.

Is there a way to determine a "wrap necessary" or "will be wrapped"
status? I could probably count the number of characters and make a
guestimate on the maximum number of characters that will fit into a
specified column witdh ... just not the best solution ...

Any ideas?

Thanks,
Joe
 
M

Mark Lincoln

If you set cell formatting to wrap text, the wrapping will be done
automatically. Does wrapped text affect something else you need to do?

The following works in Excel 2003. When run, it uses the .RowHeight
property to display a dialog box with the height of cell A1. When I
set formatting in A1 to Wrap Text, the height changed when the text was
long enough to cause wrapping.

Dim x As Integer

Sub doathing()
x = Cells(1, 1).RowHeight
MsgBox (x)
End Sub
 
J

Joe HM

Hello -

That worked! I check the RowHeight before I set the value (with
WrapText = True) and then I check the RowHeight after I set the value
and check whether it is larger.

Thanks!
Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top