#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Row Height

Hi All,
Can anyone help with this.
Is there a piece of code that will change the height of the Row/Rows if
there is data in columns.

For example:
If I had data from cells C6 through to C100, only those rows would be 15
instead of the default of 12.75. Because the data is forever changing, I
would want the rows to change with it.
Sounds rather pointless I know, but can it be done
Many thanks in advance
Regards
John

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default Row Height

This macro will scan down column C and if the cell is totally empty it will
adjust the height to the default height 12.75, else row height will be 15.

Sub RowSizer()

Dim lngLastRow As Long
Dim rng As Range

lngLastRow = Cells(Rows.Count, "C").End(xlUp).Row

For Each rng In Range("C1:C" & lngLastRow)
If IsEmpty(rng) Then
rng.RowHeight = 12.75
Else
rng.RowHeight = 15
End If
Next rng

End Sub


Hope this helps! If so, let me know, click "YES" below.
--
Cheers,
Ryan


"JohnUK" wrote:

Hi All,
Can anyone help with this.
Is there a piece of code that will change the height of the Row/Rows if
there is data in columns.

For example:
If I had data from cells C6 through to C100, only those rows would be 15
instead of the default of 12.75. Because the data is forever changing, I
would want the rows to change with it.
Sounds rather pointless I know, but can it be done
Many thanks in advance
Regards
John

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Row Height

The following procedure will make the row height resizing take place
automatically as you enter or remove data in the range C6:C100. Right click
the tab at the bottom of the worksheet you want to have this functionality,
select View Code from the popup menu that appears and then copy/paste the
following code into the code window that appears...

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("C6:C100")) Is Nothing Then
If Len(Target.Value) Then
Target.RowHeight = 15
Else
Target.RowHeight = 12.75
End If
End If
End Sub

Now, go back to your work sheet and enter something into any cell in the
range C6:C100 and watch the row height change.... now delete it and watch
the row height return to the default size of 12.75.

--
Rick (MVP - Excel)


"JohnUK" wrote in message
...
Hi All,
Can anyone help with this.
Is there a piece of code that will change the height of the Row/Rows if
there is data in columns.

For example:
If I had data from cells C6 through to C100, only those rows would be 15
instead of the default of 12.75. Because the data is forever changing, I
would want the rows to change with it.
Sounds rather pointless I know, but can it be done
Many thanks in advance
Regards
John


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default Row Height

You could actually do this too without the loop.

Sub RowSizer()

Dim lngLastRow As Long

lngLastRow = Cells(Rows.Count, "C").End(xlUp).Row

' adjust all row height to 15
Cells.RowHeight = 15

' adjust blank cell rows in Col. C to 12.75
Range("C1:C" & lngLastRow).SpecialCells(xlCellTypeBlanks).RowHeig ht =
12.75

End Sub


Hope this helps! If so, let me know, click "YES" below.
--
Cheers,
Ryan


"JohnUK" wrote:

Hi All,
Can anyone help with this.
Is there a piece of code that will change the height of the Row/Rows if
there is data in columns.

For example:
If I had data from cells C6 through to C100, only those rows would be 15
instead of the default of 12.75. Because the data is forever changing, I
would want the rows to change with it.
Sounds rather pointless I know, but can it be done
Many thanks in advance
Regards
John

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Row Height

Hey! You are both stars
Many thanks for your help

"Rick Rothstein" wrote:

The following procedure will make the row height resizing take place
automatically as you enter or remove data in the range C6:C100. Right click
the tab at the bottom of the worksheet you want to have this functionality,
select View Code from the popup menu that appears and then copy/paste the
following code into the code window that appears...

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("C6:C100")) Is Nothing Then
If Len(Target.Value) Then
Target.RowHeight = 15
Else
Target.RowHeight = 12.75
End If
End If
End Sub

Now, go back to your work sheet and enter something into any cell in the
range C6:C100 and watch the row height change.... now delete it and watch
the row height return to the default size of 12.75.

--
Rick (MVP - Excel)


"JohnUK" wrote in message
...
Hi All,
Can anyone help with this.
Is there a piece of code that will change the height of the Row/Rows if
there is data in columns.

For example:
If I had data from cells C6 through to C100, only those rows would be 15
instead of the default of 12.75. Because the data is forever changing, I
would want the rows to change with it.
Sounds rather pointless I know, but can it be done
Many thanks in advance
Regards
John


.

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
Set a minimum row height a the same time with autofit row height Julie B New Users to Excel 2 May 5th 23 07:44 PM
Row Height stopped growing and Auot-Fit Row Height does not work PSULionRP Excel Discussion (Misc queries) 0 May 19th 09 07:59 PM
the row height should be excatly the height of the data jaggu Excel Discussion (Misc queries) 2 November 6th 08 10:30 PM
Resizing row height to dynamically fit height of text box Jon Excel Discussion (Misc queries) 1 August 8th 05 01:37 PM
resize row height and column height Tom Setting up and Configuration of Excel 3 April 3rd 05 02:03 PM


All times are GMT +1. The time now is 07:51 AM.

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"