|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
help with vba excel row height
I am trying to automatically adjust the height of a row containing merged cells with wrapped text.
For whatever reason, excel won't autoscale the height when the cells are merged, so I'm left with making a macro that would adjust the row height when there are cells that need a second or more line. Is there something that would return the height the cell would or should be in order to make all the contents visible? Or, of course if you can tell me how to make excel autofit the row height that would be better... thanks |
|
#2
|
|||
|
|||
|
Hey, I couldn't find an exact solution for the problem stated, but, i'm having a work around.
Try, doing a word wrap first and then, merge the cells... |
|
#3
|
|||
|
|||
|
Adjust row height of merged cells using VBA in Microsoft Excel
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 Application.ScreenUpdating = True End Sub I find in the http://www.exceltip.com/show_tip/Fo..._Excel/341.html |
|
#4
|
|||
|
|||
|
Fundoo...
|
|
#5
|
|||
|
|||
|
Great
Quote:
worked great, although I took out the if currentheight > possheight line so it will grow or shrink the height accordingly.... |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > help with vba excel row height |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|