Conditional Row Height
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. |
Conditional Row Height
In Excel 2007, highlight the cells, column or entire worksheet where you want
the row height to adjust. On the Home tab, in the Cells group, click Format. Under Cell Size, click Autofit Row Height. (Taken from Excel 2007 Help under "Change the row height to fit the contents".) Your row height will automatically adjust to fit your cell contents. "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. |
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. |
Conditional Row Height
THenr and Sheloo. Thank you so much for responding. The Autofit Row Height
is exactly what I need, but I will also save the macro for use with another spread sheet that I have. Thanks to you both. David "THendr2929" wrote: In Excel 2007, highlight the cells, column or entire worksheet where you want the row height to adjust. On the Home tab, in the Cells group, click Format. Under Cell Size, click Autofit Row Height. (Taken from Excel 2007 Help under "Change the row height to fit the contents".) Your row height will automatically adjust to fit your cell contents. "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. |
All times are GMT +1. The time now is 08:24 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com