Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 1
Question make row height automatic

I want to reference data in another worksheet and have the row height automatically adjust to fit the data referenced.
For example: in cell A1 of Sheet1 I enter =Sheet2!B3
cell b3 in sheet2 contains a paragraph of 100 characters and column A of Sheet1 is 20 characters wide
I want cell A1 in Sheet1 to automatically adjust height to accomodate the data referenced. I have tried setting A1 to wrap and every other thing I can think of. Nothing works - so far.
Help
Thanks
  #2   Report Post  
Member
 
Posts: 54
Default

Quote:
Originally Posted by spencer
I want to reference data in another worksheet and have the row height automatically adjust to fit the data referenced.
For example: in cell A1 of Sheet1 I enter =Sheet2!B3
cell b3 in sheet2 contains a paragraph of 100 characters and column A of Sheet1 is 20 characters wide
I want cell A1 in Sheet1 to automatically adjust height to accomodate the data referenced. I have tried setting A1 to wrap and every other thing I can think of. Nothing works - so far.
Help
Thanks
This may not be the best way but this is how I accomplish this on my spreadsheets. I use a formula to calculate the row height.
=roundup(len(a1)/20,0)*12.75 where 12.75 would be your normal row height. Then I use a macro to adjust the row height to the amount calculated. You should format the cell to wrap and as the length increases it adds height appropriately.
  #3   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default make row height automatic

Formulas won't change rowheight. You'll have to rely on something else.

Since the results change because of a formula, you could use a
worksheet_calculate event.

Rightclick on the worksheet tab with the formula. Select View code and paste
this into the code window.

Option Explicit
Private Sub Worksheet_Calculate()
'specify particular row(s)
Me.Range("a6,a12,A13").entirerow.AutoFit
'or get all the rows
'Me.UsedRange.Rows.AutoFit
End Sub

You can read more about events at:
Chip Pearson's site:
http://www.cpearson.com/excel/events.htm

David McRitchie's site:
http://www.mvps.org/dmcritchie/excel/event.htm

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm


spencer wrote:

I want to reference data in another worksheet and have the row height
automatically adjust to fit the data referenced.
For example: in cell A1 of Sheet1 I enter =Sheet2!B3
cell b3 in sheet2 contains a paragraph of 100 characters and column A
of Sheet1 is 20 characters wide
I want cell A1 in Sheet1 to automatically adjust height to accomodate
the data referenced. I have tried setting A1 to wrap and every other
thing I can think of. Nothing works - so far.
Help
Thanks

--
spencer


--

Dave Peterson
  #4   Report Post  
Member
 
Posts: 54
Default

Dave,

Your right formulas won't change row height but the following macro does. I calculate the row height I want because I don't want some rows to show. Is there a better way to do this for say just a range of cells rather than the whole sheet?

' Assign the Range to the FormatRange variable
Set FormatRange = ActiveSheet.Range("Collapse")

' Loop thru the Adjust_Rows range to format the cell to its
' rowheight based on the value in the cell
For Each oCell In FormatRange

' Obtain the cell value which is the Row Height value
Cell_Width = oCell.Value

' Set the Row Height to the cell value obtained above
oCell.RowHeight = Cell_Width

Next oCell

' Turn Screen Updating ON
Application.ScreenUpdating = True

Quote:
Originally Posted by Dave Peterson
Formulas won't change rowheight. You'll have to rely on something else.

Since the results change because of a formula, you could use a
worksheet_calculate event.

Rightclick on the worksheet tab with the formula. Select View code and paste
this into the code window.

Option Explicit
Private Sub Worksheet_Calculate()
'specify particular row(s)
Me.Range("a6,a12,A13").entirerow.AutoFit
'or get all the rows
'Me.UsedRange.Rows.AutoFit
End Sub

You can read more about events at:
Chip Pearson's site:
http://www.cpearson.com/excel/events.htm

David McRitchie's site:
http://www.mvps.org/dmcritchie/excel/event.htm

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm


spencer wrote:

I want to reference data in another worksheet and have the row height
automatically adjust to fit the data referenced.
For example: in cell A1 of Sheet1 I enter =Sheet2!B3
cell b3 in sheet2 contains a paragraph of 100 characters and column A
of Sheet1 is 20 characters wide
I want cell A1 in Sheet1 to automatically adjust height to accomodate
the data referenced. I have tried setting A1 to wrap and every other
thing I can think of. Nothing works - so far.
Help
Thanks

--
spencer


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default make row height automatic

It looks like you could limit the range by just limiting what's in that Collapse
range.

Although, I'm confused about heights and widths <g.

And if you're doing this for certain rows, you'll have to keep track of the
heights someway. And it seems like a very basic (in a good way) to store that
information in that row in a dedicated column (maybe hidden??). (I've always
found updating a bunch of cells in a worksheet much simpler than fixing an array
of values in a module--especially when things can change.)

Seems like an ok approach to me.



Dave H wrote:

Dave,

Your right formulas won't change row height but the following macro
does. I calculate the row height I want because I don't want some rows
to show. Is there a better way to do this for say just a range of cells
rather than the whole sheet?

' Assign the Range to the FormatRange variable
Set FormatRange = ActiveSheet.Range("Collapse")

' Loop thru the Adjust_Rows range to format the cell to its
' rowheight based on the value in the cell
For Each oCell In FormatRange

' Obtain the cell value which is the Row Height value
Cell_Width = oCell.Value

' Set the Row Height to the cell value obtained above
oCell.RowHeight = Cell_Width

Next oCell

' Turn Screen Updating ON
Application.ScreenUpdating = True

Dave Peterson Wrote:
Formulas won't change rowheight. You'll have to rely on something
else.

Since the results change because of a formula, you could use a
worksheet_calculate event.

Rightclick on the worksheet tab with the formula. Select View code and
paste
this into the code window.

Option Explicit
Private Sub Worksheet_Calculate()
'specify particular row(s)
Me.Range("a6,a12,A13").entirerow.AutoFit
'or get all the rows
'Me.UsedRange.Rows.AutoFit
End Sub

You can read more about events at:
Chip Pearson's site:
http://www.cpearson.com/excel/events.htm

David McRitchie's site:
http://www.mvps.org/dmcritchie/excel/event.htm

If you're new to macros, you may want to read David McRitchie's intro
at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm


spencer wrote:

I want to reference data in another worksheet and have the row height
automatically adjust to fit the data referenced.
For example: in cell A1 of Sheet1 I enter =Sheet2!B3
cell b3 in sheet2 contains a paragraph of 100 characters and column A
of Sheet1 is 20 characters wide
I want cell A1 in Sheet1 to automatically adjust height to accomodate
the data referenced. I have tried setting A1 to wrap and every other
thing I can think of. Nothing works - so far.
Help
Thanks

--
spencer

--

Dave Peterson


--
Dave H


--

Dave Peterson
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
enable automatic refresh Vass Excel Worksheet Functions 2 March 11th 06 04:36 AM
What is the trick to make rows resize height automatically? Gumby Excel Discussion (Misc queries) 3 July 13th 05 07:12 PM
Automatic Row Height ciny Excel Discussion (Misc queries) 1 January 26th 05 09:55 PM
Change height of row Pam MacT Excel Discussion (Misc queries) 2 January 5th 05 01:54 AM
How do I make Excel automatically adjust a row's height once I in. sueuy Excel Worksheet Functions 1 December 2nd 04 05:35 PM


All times are GMT +1. The time now is 07:07 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"