Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
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. |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
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. |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
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. |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
need to dbl row height without changing height of cell next to it | New Users to Excel | |||
Resizing row height to dynamically fit height of text box | Excel Discussion (Misc queries) | |||
How to edit row height with conditional formatting? | Excel Discussion (Misc queries) | |||
resize row height and column height | Setting up and Configuration of Excel | |||
Row height | Excel Discussion (Misc queries) |