Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Autofit and word wrap don't work?

I have a worksheet that has rows formatted to auto fit and cells formatted to
word wrap, but the cells do not auto adjust to input data. The column is set
to a width of 40. If the input string is over 39 characters long, the cell
stays 1 row high until the character length exceeds 51. I have tried the
attached code from Gord Dibben, but it does not resolve the problem.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim NewRwHt As Single
Dim cWdth As Single, MrgeWdth As Single
Dim c As Range, cc As Range
Dim ma As Range

With Target
If .MergeCells And .WrapText Then
Set c = Target.Cells(1, 1)
cWdth = c.ColumnWidth
Set ma = c.MergeArea
For Each cc In ma.Cells
MrgeWdth = MrgeWdth + cc.ColumnWidth
Next
Application.ScreenUpdating = False
ma.MergeCells = False
c.ColumnWidth = MrgeWdth
c.EntireRow.AutoFit
NewRwHt = c.RowHeight
c.ColumnWidth = cWdth
ma.MergeCells = True
ma.RowHeight = NewRwHt
cWdth = 0: MrgeWdth = 0
Application.ScreenUpdating = True
End If
End With
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Autofit and word wrap don't work?

Jack

The width set at 40 does not govern how many characters will show before the
text will wrap or autofit.

The number that appears in the Standard column width box is the average number
of digits 0-9 of the standard font that fit in a cell.

Depending upon the characters that could be more or less.

I tested with the letter "i" and got 93 before wrapping or autofit took place.

With "w" it took only 30.

Formatted as 10 point Arial Font.


Gord Dibben MS Excel MVP

On Tue, 9 Jan 2007 08:46:00 -0800, Jack Greb <Jack
wrote:

I have a worksheet that has rows formatted to auto fit and cells formatted to
word wrap, but the cells do not auto adjust to input data. The column is set
to a width of 40. If the input string is over 39 characters long, the cell
stays 1 row high until the character length exceeds 51. I have tried the
attached code from Gord Dibben, but it does not resolve the problem.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim NewRwHt As Single
Dim cWdth As Single, MrgeWdth As Single
Dim c As Range, cc As Range
Dim ma As Range

With Target
If .MergeCells And .WrapText Then
Set c = Target.Cells(1, 1)
cWdth = c.ColumnWidth
Set ma = c.MergeArea
For Each cc In ma.Cells
MrgeWdth = MrgeWdth + cc.ColumnWidth
Next
Application.ScreenUpdating = False
ma.MergeCells = False
c.ColumnWidth = MrgeWdth
c.EntireRow.AutoFit
NewRwHt = c.RowHeight
c.ColumnWidth = cWdth
ma.MergeCells = True
ma.RowHeight = NewRwHt
cWdth = 0: MrgeWdth = 0
Application.ScreenUpdating = True
End If
End With
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default Autofit and word wrap don't work?

I mentioned the width vs length only to demonstrate that here were an excess
number of characters required before the wrap takes place. This leaves some
of the characters hidden if they are below the magic threshhold. What I need
is a method to wrap as soon as a character string exceeds what can be seen.

"Gord Dibben" wrote:

Jack

The width set at 40 does not govern how many characters will show before the
text will wrap or autofit.

The number that appears in the Standard column width box is the average number
of digits 0-9 of the standard font that fit in a cell.

Depending upon the characters that could be more or less.

I tested with the letter "i" and got 93 before wrapping or autofit took place.

With "w" it took only 30.

Formatted as 10 point Arial Font.


Gord Dibben MS Excel MVP

On Tue, 9 Jan 2007 08:46:00 -0800, Jack Greb <Jack
wrote:

I have a worksheet that has rows formatted to auto fit and cells formatted to
word wrap, but the cells do not auto adjust to input data. The column is set
to a width of 40. If the input string is over 39 characters long, the cell
stays 1 row high until the character length exceeds 51. I have tried the
attached code from Gord Dibben, but it does not resolve the problem.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim NewRwHt As Single
Dim cWdth As Single, MrgeWdth As Single
Dim c As Range, cc As Range
Dim ma As Range

With Target
If .MergeCells And .WrapText Then
Set c = Target.Cells(1, 1)
cWdth = c.ColumnWidth
Set ma = c.MergeArea
For Each cc In ma.Cells
MrgeWdth = MrgeWdth + cc.ColumnWidth
Next
Application.ScreenUpdating = False
ma.MergeCells = False
c.ColumnWidth = MrgeWdth
c.EntireRow.AutoFit
NewRwHt = c.RowHeight
c.ColumnWidth = cWdth
ma.MergeCells = True
ma.RowHeight = NewRwHt
cWdth = 0: MrgeWdth = 0
Application.ScreenUpdating = True
End If
End With
End Sub



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default Autofit and word wrap don't work?



I mentioned the width vs length only to demonstrate that here were an excess
number of characters required before the wrap takes place. This leaves some
of the characters hidden if they are below the magic threshold. What I need
is a method to wrap as soon as a character string exceeds what can be seen.

"Gord Dibben" wrote:

Jack

The width set at 40 does not govern how many characters will show before the
text will wrap or autofit.

The number that appears in the Standard column width box is the average number
of digits 0-9 of the standard font that fit in a cell.

Depending upon the characters that could be more or less.

I tested with the letter "i" and got 93 before wrapping or autofit took place.

With "w" it took only 30.

Formatted as 10 point Arial Font.


Gord Dibben MS Excel MVP

On Tue, 9 Jan 2007 08:46:00 -0800, Jack Greb <Jack
wrote:

I have a worksheet that has rows formatted to auto fit and cells formatted to
word wrap, but the cells do not auto adjust to input data. The column is set
to a width of 40. If the input string is over 39 characters long, the cell
stays 1 row high until the character length exceeds 51. I have tried the
attached code from Gord Dibben, but it does not resolve the problem.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim NewRwHt As Single
Dim cWdth As Single, MrgeWdth As Single
Dim c As Range, cc As Range
Dim ma As Range

With Target
If .MergeCells And .WrapText Then
Set c = Target.Cells(1, 1)
cWdth = c.ColumnWidth
Set ma = c.MergeArea
For Each cc In ma.Cells
MrgeWdth = MrgeWdth + cc.ColumnWidth
Next
Application.ScreenUpdating = False
ma.MergeCells = False
c.ColumnWidth = MrgeWdth
c.EntireRow.AutoFit
NewRwHt = c.RowHeight
c.ColumnWidth = cWdth
ma.MergeCells = True
ma.RowHeight = NewRwHt
cWdth = 0: MrgeWdth = 0
Application.ScreenUpdating = True
End If
End With
End Sub




  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Autofit and word wrap don't work?

Jack

I don't have an answer for your problem.

I cannot replicate it. When I enter text in a wrap-text autofit cell the text
wraps and the row re-sizes when it reaches the end of the column width.

Are you dealing with "merged cells"?

They can cause problems.

Maybe another watcher can contribute something.


Gord

On Wed, 10 Jan 2007 15:21:00 -0800, Jack Greb
wrote:



I mentioned the width vs length only to demonstrate that here were an excess
number of characters required before the wrap takes place. This leaves some
of the characters hidden if they are below the magic threshold. What I need
is a method to wrap as soon as a character string exceeds what can be seen.

"Gord Dibben" wrote:

Jack

The width set at 40 does not govern how many characters will show before the
text will wrap or autofit.

The number that appears in the Standard column width box is the average number
of digits 0-9 of the standard font that fit in a cell.

Depending upon the characters that could be more or less.

I tested with the letter "i" and got 93 before wrapping or autofit took place.

With "w" it took only 30.

Formatted as 10 point Arial Font.


Gord Dibben MS Excel MVP

On Tue, 9 Jan 2007 08:46:00 -0800, Jack Greb <Jack
wrote:

I have a worksheet that has rows formatted to auto fit and cells formatted to
word wrap, but the cells do not auto adjust to input data. The column is set
to a width of 40. If the input string is over 39 characters long, the cell
stays 1 row high until the character length exceeds 51. I have tried the
attached code from Gord Dibben, but it does not resolve the problem.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim NewRwHt As Single
Dim cWdth As Single, MrgeWdth As Single
Dim c As Range, cc As Range
Dim ma As Range

With Target
If .MergeCells And .WrapText Then
Set c = Target.Cells(1, 1)
cWdth = c.ColumnWidth
Set ma = c.MergeArea
For Each cc In ma.Cells
MrgeWdth = MrgeWdth + cc.ColumnWidth
Next
Application.ScreenUpdating = False
ma.MergeCells = False
c.ColumnWidth = MrgeWdth
c.EntireRow.AutoFit
NewRwHt = c.RowHeight
c.ColumnWidth = cWdth
ma.MergeCells = True
ma.RowHeight = NewRwHt
cWdth = 0: MrgeWdth = 0
Application.ScreenUpdating = True
End If
End With
End Sub






  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default Autofit and word wrap don't work?

Gord,
I can send you a copy of the shet if you can provide me with an address.
Perhaps you will be able to spot the problem.

"Gord Dibben" wrote:

Jack

I don't have an answer for your problem.

I cannot replicate it. When I enter text in a wrap-text autofit cell the text
wraps and the row re-sizes when it reaches the end of the column width.

Are you dealing with "merged cells"?

They can cause problems.

Maybe another watcher can contribute something.


Gord

On Wed, 10 Jan 2007 15:21:00 -0800, Jack Greb
wrote:



I mentioned the width vs length only to demonstrate that here were an excess
number of characters required before the wrap takes place. This leaves some
of the characters hidden if they are below the magic threshold. What I need
is a method to wrap as soon as a character string exceeds what can be seen.

"Gord Dibben" wrote:

Jack

The width set at 40 does not govern how many characters will show before the
text will wrap or autofit.

The number that appears in the Standard column width box is the average number
of digits 0-9 of the standard font that fit in a cell.

Depending upon the characters that could be more or less.

I tested with the letter "i" and got 93 before wrapping or autofit took place.

With "w" it took only 30.

Formatted as 10 point Arial Font.


Gord Dibben MS Excel MVP

On Tue, 9 Jan 2007 08:46:00 -0800, Jack Greb <Jack
wrote:

I have a worksheet that has rows formatted to auto fit and cells formatted to
word wrap, but the cells do not auto adjust to input data. The column is set
to a width of 40. If the input string is over 39 characters long, the cell
stays 1 row high until the character length exceeds 51. I have tried the
attached code from Gord Dibben, but it does not resolve the problem.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim NewRwHt As Single
Dim cWdth As Single, MrgeWdth As Single
Dim c As Range, cc As Range
Dim ma As Range

With Target
If .MergeCells And .WrapText Then
Set c = Target.Cells(1, 1)
cWdth = c.ColumnWidth
Set ma = c.MergeArea
For Each cc In ma.Cells
MrgeWdth = MrgeWdth + cc.ColumnWidth
Next
Application.ScreenUpdating = False
ma.MergeCells = False
c.ColumnWidth = MrgeWdth
c.EntireRow.AutoFit
NewRwHt = c.RowHeight
c.ColumnWidth = cWdth
ma.MergeCells = True
ma.RowHeight = NewRwHt
cWdth = 0: MrgeWdth = 0
Application.ScreenUpdating = True
End If
End With
End Sub




  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Autofit and word wrap don't work?

Jack sent me the workbook.

Text is not wrapping until well past the right cell boundary.

As Jack points out....should wrap at 40 chars but doesn't wrap until 51 chars
are reached.

Zoom settings are at 60% for the sheet which causes the problem in my
estimation.

By re-setting to 80% or above the text wraps where it should and autofit takes
place.

Anybody have any suggestions other than "increase the zoom".


Gord


On Wed, 10 Jan 2007 17:37:25 -0800, Gord Dibben <gorddibbATshawDOTca wrote:

Jack

I don't have an answer for your problem.

I cannot replicate it. When I enter text in a wrap-text autofit cell the text
wraps and the row re-sizes when it reaches the end of the column width.

Are you dealing with "merged cells"?

They can cause problems.

Maybe another watcher can contribute something.


Gord

On Wed, 10 Jan 2007 15:21:00 -0800, Jack Greb
wrote:



I mentioned the width vs length only to demonstrate that here were an excess
number of characters required before the wrap takes place. This leaves some
of the characters hidden if they are below the magic threshold. What I need
is a method to wrap as soon as a character string exceeds what can be seen.

"Gord Dibben" wrote:

Jack

The width set at 40 does not govern how many characters will show before the
text will wrap or autofit.

The number that appears in the Standard column width box is the average number
of digits 0-9 of the standard font that fit in a cell.

Depending upon the characters that could be more or less.

I tested with the letter "i" and got 93 before wrapping or autofit took place.

With "w" it took only 30.

Formatted as 10 point Arial Font.


Gord Dibben MS Excel MVP

On Tue, 9 Jan 2007 08:46:00 -0800, Jack Greb <Jack
wrote:

I have a worksheet that has rows formatted to auto fit and cells formatted to
word wrap, but the cells do not auto adjust to input data. The column is set
to a width of 40. If the input string is over 39 characters long, the cell
stays 1 row high until the character length exceeds 51. I have tried the
attached code from Gord Dibben, but it does not resolve the problem.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim NewRwHt As Single
Dim cWdth As Single, MrgeWdth As Single
Dim c As Range, cc As Range
Dim ma As Range

With Target
If .MergeCells And .WrapText Then
Set c = Target.Cells(1, 1)
cWdth = c.ColumnWidth
Set ma = c.MergeArea
For Each cc In ma.Cells
MrgeWdth = MrgeWdth + cc.ColumnWidth
Next
Application.ScreenUpdating = False
ma.MergeCells = False
c.ColumnWidth = MrgeWdth
c.EntireRow.AutoFit
NewRwHt = c.RowHeight
c.ColumnWidth = cWdth
ma.MergeCells = True
ma.RowHeight = NewRwHt
cWdth = 0: MrgeWdth = 0
Application.ScreenUpdating = True
End If
End With
End Sub



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
Word wrapping in Excel JD2 Excel Discussion (Misc queries) 11 October 15th 12 04:45 PM
Autofit doesn't work Rosemary Excel Discussion (Misc queries) 1 October 6th 06 04:21 AM
How to make (XL) Merge Cells and Word Wrap work concurrently? George D. Excel Discussion (Misc queries) 1 May 2nd 06 05:41 PM
AutoFit rows issue stego Excel Discussion (Misc queries) 0 February 28th 06 09:39 PM
Text disappears when word wrap is used Mark_GS1CA Excel Discussion (Misc queries) 12 October 17th 05 12:44 PM


All times are GMT +1. The time now is 12:04 PM.

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"