Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 266
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8
Default 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   Report Post  
Posted to microsoft.public.excel.misc
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.


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 266
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
need to dbl row height without changing height of cell next to it Excel-Illiterate New Users to Excel 1 May 16th 06 01:08 AM
Resizing row height to dynamically fit height of text box Jon Excel Discussion (Misc queries) 1 August 8th 05 01:37 PM
How to edit row height with conditional formatting? CDAK Excel Discussion (Misc queries) 4 June 12th 05 06:41 PM
resize row height and column height Tom Setting up and Configuration of Excel 3 April 3rd 05 02:03 PM
Row height Sharon Excel Discussion (Misc queries) 1 February 18th 05 01:39 AM


All times are GMT +1. The time now is 08:35 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"