Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to show wraped text in merged cells

Has anybody written a macro that will set the correct row
height to display all of the text in horizontally merged
cells in a single row? The problem arises if you merge
(say) 4 cells and then enter text which is greater than
the width of those cells and select wrap text.
The "excess" text disappears from view, but reappears
properly wrapped if you double the row height. So the
macro needs to know the size of the entered text and the
width of the merged cells and could then presumably
adjust the row height accordingly.
Or is there another way? Unfortunately text boxes are of
no use in the application I need this for.
Many thanks in advance to any helpers.
MBK

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Macro to show wraped text in merged cells

This works on the active cell.

''Simulates row height autofit for a merged cell if the active cell..
'' is merged.
'' has Wrap Text set.
'' includes only 1 row.
''Unlike real autosizing the macro only increases row height
'' (if needed). It does not reduce row height (because another
'' merged cell on the same row may needed a greater height
'' than the active cell).
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


--
Jim Rech
Excel MVP
"Milky Bar Kid" wrote in message
...
| Has anybody written a macro that will set the correct row
| height to display all of the text in horizontally merged
| cells in a single row? The problem arises if you merge
| (say) 4 cells and then enter text which is greater than
| the width of those cells and select wrap text.
| The "excess" text disappears from view, but reappears
| properly wrapped if you double the row height. So the
| macro needs to know the size of the entered text and the
| width of the merged cells and could then presumably
| adjust the row height accordingly.
| Or is there another way? Unfortunately text boxes are of
| no use in the application I need this for.
| Many thanks in advance to any helpers.
| MBK
|


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
How do I get the a large amount of text to show in merged cell? Jennifer H. Excel Discussion (Misc queries) 2 October 5th 06 08:11 PM
Aligning Wraped Text to the bottom of a cell Viking Excel Discussion (Misc queries) 2 July 7th 06 09:33 PM
Show centered text along merged colum cells BLopes Excel Discussion (Misc queries) 0 June 26th 06 11:01 PM
Autofit with Merged Cells/Wrap Text Macro Problem elfmajesty Excel Discussion (Misc queries) 3 May 25th 06 06:32 PM
Merged Cell will initally show text from 1st worksheet but then wo neil57 Excel Worksheet Functions 4 April 5th 05 09:01 PM


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