View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Sheeloo[_3_] Sheeloo[_3_] is offline
external usenet poster
 
Posts: 1,805
Default Conditional Row Height

Try
'The macro lloks for ASCII character 10 (ALT-ENTER)
'and adjusts height accordingly

Sub rowHeight()
Dim str As String
Dim i, j, k, ht, lastRow As Long
With ActiveSheet
lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row + 1
End With
For k = 1 To lastRow
Cells(k, 1).Select
str = Selection.Value
j = 0
For i = 1 To Len(str)
c = Mid(str, i, 1)
If c = Chr(10) Then
j = j + 1
End If
Next
If j = 0 Then
ht = 0
Else
ht = 12.8 * j
End If
Selection.rowHeight = ht
Next
End Sub

"dhstein" wrote:

I have a cell that may have no data or from 1 to 6 lines of data. Is there a
way to make the Row Height conditional based on the number of lines of data
in the cell? Thanks.