View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
SteveZmyname SteveZmyname is offline
external usenet poster
 
Posts: 30
Default Minimum row height

Thanks Gary
This code looks excellent. Do I put this in a code module?
How do I activate or call the ChangeHeight procedure?
Sorry for the newbie questions.

"Gary Brown" wrote:

'/========================================/
' Sub Purpose: make all rows iHeight or greater
'/========================================/
'
Public Sub ChangeHeight()
Dim dbl As Double
Dim dblLastRow As Double
Dim iHeight As Integer
Dim strSelection As String

On Error GoTo err_Sub

'variable height
iHeight = 105

'save original selection
strSelection = Selection.Address

'autofit all rows
Cells.EntireRow.AutoFit

'get last row in worksheet
dblLastRow = ActiveSheet.Cells.SpecialCells(xlLastCell).Row

'loop through all rows, if height < desired, make desired height
For dbl = 1 To dblLastRow
If Range("A1").Offset(dbl - 1, 0).RowHeight < iHeight Then
Range("A1").Offset(dbl - 1, 0).RowHeight = iHeight
End If
Next dbl

exit_Sub:
On Error Resume Next
Exit Sub

err_Sub:
Debug.Print "Error: " & Err.Number & " - (" & _
Err.Description & _
") - Sub: " & _
"ChangeHeight - " & Now()
GoTo exit_Sub

End Sub
'/========================================/

--
Hope this helps.
If it does, please click the Yes button.
Thanks in advance for your feedback.
Gary Brown



"SteveZmyname" wrote:

Hello
I'm using the auto fit row height and it works very well but what if I want
to set a minimum row height such as 105 and have it expand only if it is
greater than that?

thanks