LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 21
Default Automatically re-sizing merged cells

Sorry - didn't notice I was still in the FUNCTIONS group. I will take this to
the PROGRAMMING group.

"LongTermNoob" wrote:

I have created a workbook with one sheet for inputting information, and
several other sheets containing the printed forms required for this job.

Some of these cells contain text, and the amount entered varies dramatically
from project to project. I therefor need to auto size the rows involved - and
have to use a macro as they are merged cells. The macro is run using the
change_worksheet private function and is shown below. It works well for
individual cells, but I would like it to run on the corresponding cells in
the other worksheets when the cell on the input sheet is altered.

Any siggestions gratefully received.


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Target, Range("E12:R12")) Is Nothing Then
Exit Sub
Else
Range("E12:R12").Select
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 If
End Sub

 
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 can I automatically expand merged cells to fit text in excel Michelle Bance Excel Discussion (Misc queries) 1 February 19th 07 02:19 PM
automatically sizing text with graphs Shoque Charts and Charting in Excel 1 August 2nd 06 03:30 PM
how do i link merged cells to a merged cell in another worksheet. ibbm Excel Worksheet Functions 3 April 27th 06 11:40 PM
automatically fit an image into merged cells dave Excel Discussion (Misc queries) 1 January 26th 05 11:54 AM
Sorting merged cellsHow do I sort merged cells not identically siz Laval Excel Worksheet Functions 1 November 3rd 04 09:40 PM


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