LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Jim Rech
 
Posts: n/a
Default

Kelli's merged cell did not have word wrap set for the entire merged cell,
just the first cell in it. This is a situation I hadn't anticipated but an
easy shortcoming to fix (I think):

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 .Cells(1).WrapText = True Then
''<<.Cells(1) added
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
"Jim Rech" wrote in message
...

--
Jim Rech
Excel MVP
"kchambers" wrote in message
...
| Jim,
| The row height is not expanding to fit all the characters within the
cell.
| I am not very familar with macros. I just started working on them last
week.
| I don't mind sending you the workbook so you can look at it. How do I
get
| your email address?
|
| "Jim Rech" wrote:
|
| You didn't specify exactly how it fails. Just in case the problem is
that
| the macro is not shrinking the row height, I should mention it is
design
| only to increase row heights if needed. The reason being that there
could
| be other merged cells on the same row that need the greater row
height.
|
| Maybe you could copy/paste the problem merged cell into a new workbook
and
| send it to me, once you verify that the problem reproduces in it of
course..
|
| --
| Jim Rech
| Excel MVP
| "kchambers" wrote in message
| ...
| | Yes, I do have wrap text selected.
| |
| | "Jim Rech" wrote:
| |
| | There are three requirements and you mentioned 2. Is Wrap Text
set
for
| the
| | active cell?
| |
| | --
| | Jim Rech
| | Excel MVP
| | "kchambers" wrote in message
| | ...
| | |I have tried to use Jim Rech's macro to autofit a merged cell in
excel.
| | | However, I cannot seem to get this to work for my situation. I
have
| (1)
| | row
| | | merged in (2) columns (D & E.) What am I doing wrong???
| |
| |
| |
|
|
|




 
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
Excel 97 - Selecting multiple cells from 2 different Pivot Tables jjones_HAB Excel Discussion (Misc queries) 0 March 1st 05 12:01 PM
automatically fit an image into merged cells dave Excel Discussion (Misc queries) 1 January 26th 05 11:54 AM
How do I protect specific cells from changes in Excel? LarryH Excel Discussion (Misc queries) 2 January 25th 05 10:10 PM
Adding contents of cells by clicking in Excel 2002 Kevin Gordon Excel Discussion (Misc queries) 7 January 11th 05 04:49 PM
I need help getting Excel to auto-fill cells when I begin typing . todd New Users to Excel 2 January 7th 05 03:07 PM


All times are GMT +1. The time now is 09:06 AM.

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"