PC Review


Reply
Thread Tools Rate Thread

Automatically Change Row Height Based on Cell Contents?

 
 
samcham
Guest
Posts: n/a
 
      7th May 2008
Is there a way to change the row height based on the contents of a cell?

Here's what I've done:

1. I have a worksheet with about 6,000 or so lines, containing data for
over 100 departments.

2. I've created Subtotals, and used Ron DeBruin's code to create separate
worksheets for each department.

3. The subtotals came over to the individual worksheets just fine. Now I
want to change the row height of the rows that contain the subtotals to 25,
so the worksheets are easier to read. Each of the subtotal rows has the word
"Total" included in the entry in column B.

Is there a way to automate this task?

Thanks,

Sam.
 
Reply With Quote
 
 
 
 
Office_Novice
Guest
Posts: n/a
 
      7th May 2008
Try Columns("B") .AutoFit

"samcham" wrote:

> Is there a way to change the row height based on the contents of a cell?
>
> Here's what I've done:
>
> 1. I have a worksheet with about 6,000 or so lines, containing data for
> over 100 departments.
>
> 2. I've created Subtotals, and used Ron DeBruin's code to create separate
> worksheets for each department.
>
> 3. The subtotals came over to the individual worksheets just fine. Now I
> want to change the row height of the rows that contain the subtotals to 25,
> so the worksheets are easier to read. Each of the subtotal rows has the word
> "Total" included in the entry in column B.
>
> Is there a way to automate this task?
>
> Thanks,
>
> Sam.

 
Reply With Quote
 
samcham
Guest
Posts: n/a
 
      7th May 2008
How will that change the row height?

"Office_Novice" wrote:

> Try Columns("B") .AutoFit
>
> "samcham" wrote:
>
> > Is there a way to change the row height based on the contents of a cell?
> >
> > Here's what I've done:
> >
> > 1. I have a worksheet with about 6,000 or so lines, containing data for
> > over 100 departments.
> >
> > 2. I've created Subtotals, and used Ron DeBruin's code to create separate
> > worksheets for each department.
> >
> > 3. The subtotals came over to the individual worksheets just fine. Now I
> > want to change the row height of the rows that contain the subtotals to 25,
> > so the worksheets are easier to read. Each of the subtotal rows has the word
> > "Total" included in the entry in column B.
> >
> > Is there a way to automate this task?
> >
> > Thanks,
> >
> > Sam.

 
Reply With Quote
 
Office_Novice
Guest
Posts: n/a
 
      7th May 2008
.AutoFit Will adjust the cells in the defined range to fit the contents of
the cells in that range

"samcham" wrote:

> How will that change the row height?
>
> "Office_Novice" wrote:
>
> > Try Columns("B") .AutoFit
> >
> > "samcham" wrote:
> >
> > > Is there a way to change the row height based on the contents of a cell?
> > >
> > > Here's what I've done:
> > >
> > > 1. I have a worksheet with about 6,000 or so lines, containing data for
> > > over 100 departments.
> > >
> > > 2. I've created Subtotals, and used Ron DeBruin's code to create separate
> > > worksheets for each department.
> > >
> > > 3. The subtotals came over to the individual worksheets just fine. Now I
> > > want to change the row height of the rows that contain the subtotals to 25,
> > > so the worksheets are easier to read. Each of the subtotal rows has the word
> > > "Total" included in the entry in column B.
> > >
> > > Is there a way to automate this task?
> > >
> > > Thanks,
> > >
> > > Sam.

 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      7th May 2008
This should do what you want. Test it on a copy before permanent installation.

Sub colBrwHgt()
Dim lastRow As Long, wks As Worksheet
lastRow = ActiveSheet.Cells(Rows.Count, 2).End(xlUp).Row
Set wks = ActiveSheet
For Each c In wks.Range("B2:B" & lastRow)
If c.Value Like "*Total*" Then
c.EntireRow.RowHeight = 25
End If
Next
End Sub

"samcham" wrote:

> Is there a way to change the row height based on the contents of a cell?
>
> Here's what I've done:
>
> 1. I have a worksheet with about 6,000 or so lines, containing data for
> over 100 departments.
>
> 2. I've created Subtotals, and used Ron DeBruin's code to create separate
> worksheets for each department.
>
> 3. The subtotals came over to the individual worksheets just fine. Now I
> want to change the row height of the rows that contain the subtotals to 25,
> so the worksheets are easier to read. Each of the subtotal rows has the word
> "Total" included in the entry in column B.
>
> Is there a way to automate this task?
>
> Thanks,
>
> Sam.

 
Reply With Quote
 
samcham
Guest
Posts: n/a
 
      7th May 2008
Thanks, but I'm not trying to autofit to the contents. I'm trying to
increase the row height for rows that contain the subtotals. The height of
those rows is already autofit to the contents, but I want it to be greater.
For example, the autofit height is 12, but I want it to be 25 if there's a
subtotal on that line.

Sam.

"Office_Novice" wrote:

> .AutoFit Will adjust the cells in the defined range to fit the contents of
> the cells in that range
>
> "samcham" wrote:
>
> > How will that change the row height?
> >
> > "Office_Novice" wrote:
> >
> > > Try Columns("B") .AutoFit
> > >
> > > "samcham" wrote:
> > >
> > > > Is there a way to change the row height based on the contents of a cell?
> > > >
> > > > Here's what I've done:
> > > >
> > > > 1. I have a worksheet with about 6,000 or so lines, containing data for
> > > > over 100 departments.
> > > >
> > > > 2. I've created Subtotals, and used Ron DeBruin's code to create separate
> > > > worksheets for each department.
> > > >
> > > > 3. The subtotals came over to the individual worksheets just fine. Now I
> > > > want to change the row height of the rows that contain the subtotals to 25,
> > > > so the worksheets are easier to read. Each of the subtotal rows has the word
> > > > "Total" included in the entry in column B.
> > > >
> > > > Is there a way to automate this task?
> > > >
> > > > Thanks,
> > > >
> > > > Sam.

 
Reply With Quote
 
samcham
Guest
Posts: n/a
 
      7th May 2008
PERFECT! Thank you very much!

Sam.

"JLGWhiz" wrote:

> This should do what you want. Test it on a copy before permanent installation.
>
> Sub colBrwHgt()
> Dim lastRow As Long, wks As Worksheet
> lastRow = ActiveSheet.Cells(Rows.Count, 2).End(xlUp).Row
> Set wks = ActiveSheet
> For Each c In wks.Range("B2:B" & lastRow)
> If c.Value Like "*Total*" Then
> c.EntireRow.RowHeight = 25
> End If
> Next
> End Sub
>
> "samcham" wrote:
>
> > Is there a way to change the row height based on the contents of a cell?
> >
> > Here's what I've done:
> >
> > 1. I have a worksheet with about 6,000 or so lines, containing data for
> > over 100 departments.
> >
> > 2. I've created Subtotals, and used Ron DeBruin's code to create separate
> > worksheets for each department.
> >
> > 3. The subtotals came over to the individual worksheets just fine. Now I
> > want to change the row height of the rows that contain the subtotals to 25,
> > so the worksheets are easier to read. Each of the subtotal rows has the word
> > "Total" included in the entry in column B.
> >
> > Is there a way to automate this task?
> >
> > Thanks,
> >
> > Sam.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
making a row height automatically adjust to cell contents John Microsoft Access Database Table Design 2 6th Jan 2010 11:38 PM
text box on form - automatically adjust height based on contents Paul Kraemer Microsoft Access Forms 6 10th Jul 2008 12:26 PM
set row height based on contents of cell keyser_Soze@usa.com Microsoft Excel Discussion 1 29th Sep 2005 06:47 PM
How to fit a row height to a cell contents automatically? Dmitriy Kopnichev Microsoft Excel Misc 3 19th Aug 2003 01:49 PM
How to fit a row height to a cell contents automatically? Dmitriy Kopnichev Microsoft Excel Discussion 2 19th Aug 2003 01:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:04 AM.