Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default merged cells and wrapping text

I have merged a few adjacent cells in a row, then asked Excel to wrap the
text with the merged cell. It refuses.

I was originally trying to do this in code, but I now find that it can't be
done even when I try and do it manually.
(Using Office XP)


Anyone know a work-around?

cheers


Rod


  #2   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default merged cells and wrapping text

Try the following code:

Sub alpha()
With Range("a1:b4")
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlTop
.WrapText = True
.MergeCells = True
End With
End Sub

Regards,

Alasdair Stirling

"Rod" wrote:

I have merged a few adjacent cells in a row, then asked Excel to wrap the
text with the merged cell. It refuses.

I was originally trying to do this in code, but I now find that it can't be
done even when I try and do it manually.
(Using Office XP)


Anyone know a work-around?

cheers


Rod



  #3   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default merged cells and wrapping text

thanks
but this only works because you have gone down to row 4.
I don't know how much text will be in cell a1 so I just want it to increase
the row height to accommodate the text in the same way Wrap works for a
single unmerged cell.

the problem is the same even if done manually without code.
As far as I can see there is no way of measuring how many lines the text
should flow onto and adjusting the row height by code either



"Alasdair Stirling" wrote in
message ...
Try the following code:

Sub alpha()
With Range("a1:b4")
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlTop
.WrapText = True
.MergeCells = True
End With
End Sub

Regards,

Alasdair Stirling

"Rod" wrote:

I have merged a few adjacent cells in a row, then asked Excel to wrap

the
text with the merged cell. It refuses.

I was originally trying to do this in code, but I now find that it can't

be
done even when I try and do it manually.
(Using Office XP)


Anyone know a work-around?

cheers


Rod





  #4   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default merged cells and wrapping text

Merged cells done support Autofit.

You might pursue some code like this posted by Jim Rech:

Jim Rech

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

--
Regards,
Tom Ogilvy

"Rod" wrote in message
...
thanks
but this only works because you have gone down to row 4.
I don't know how much text will be in cell a1 so I just want it to

increase
the row height to accommodate the text in the same way Wrap works for a
single unmerged cell.

the problem is the same even if done manually without code.
As far as I can see there is no way of measuring how many lines the text
should flow onto and adjusting the row height by code either



"Alasdair Stirling" wrote in
message ...
Try the following code:

Sub alpha()
With Range("a1:b4")
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlTop
.WrapText = True
.MergeCells = True
End With
End Sub

Regards,

Alasdair Stirling

"Rod" wrote:

I have merged a few adjacent cells in a row, then asked Excel to wrap

the
text with the merged cell. It refuses.

I was originally trying to do this in code, but I now find that it

can't
be
done even when I try and do it manually.
(Using Office XP)


Anyone know a work-around?

cheers


Rod







  #5   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default merged cells and wrapping text

Thanks for this it looks good


"Tom Ogilvy" wrote in message
...
Merged cells done support Autofit.

You might pursue some code like this posted by Jim Rech:

Jim Rech

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

--
Regards,
Tom Ogilvy

"Rod" wrote in message
...
thanks
but this only works because you have gone down to row 4.
I don't know how much text will be in cell a1 so I just want it to

increase
the row height to accommodate the text in the same way Wrap works for a
single unmerged cell.

the problem is the same even if done manually without code.
As far as I can see there is no way of measuring how many lines the text
should flow onto and adjusting the row height by code either



"Alasdair Stirling" wrote

in
message ...
Try the following code:

Sub alpha()
With Range("a1:b4")
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlTop
.WrapText = True
.MergeCells = True
End With
End Sub

Regards,

Alasdair Stirling

"Rod" wrote:

I have merged a few adjacent cells in a row, then asked Excel to

wrap
the
text with the merged cell. It refuses.

I was originally trying to do this in code, but I now find that it

can't
be
done even when I try and do it manually.
(Using Office XP)


Anyone know a work-around?

cheers


Rod









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
Wrapping Text in Merged Cells brigla5 Excel Worksheet Functions 4 October 18th 09 03:28 AM
Wrapping Text in Merged Cells - Excel 2002 Cornelia Excel Discussion (Misc queries) 0 April 30th 09 07:06 PM
Wrapping text in merged cells JRTB Excel Discussion (Misc queries) 4 January 24th 09 08:21 AM
wrapping text in merged cells Ann Excel Discussion (Misc queries) 2 April 3rd 08 04:51 PM
Wrapping text in merged cells Taza Excel Discussion (Misc queries) 3 January 16th 07 08:56 AM


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