The Code Cage - Microsoft Office help Free Microsoft Office Help for all Applications!  

To stop seeing these ads and get other benefits check This page!

Go Back   The Code Cage Forums > Newsgroups - Microsoft Topics > Newsgroup - Excel Forum > Worksheet Functions


Worksheet Functions Post questions in this forum if they are related to using Microsoft Excel Worksheet Functions, e.g Forumale or built in functionality etc.

Hey there!

It looks like you're enjoying but haven't created an account yet. Why not take a minute to register for your own free account now? As a member you get free access to all of our forums and posts plus the ability to post your own messages, communicate directly with other members and much more. Register now!

Already a member? Login at the top of this page to stop seeing this message.


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 5th December 2008, 10:52 PM
Datadonna
Newsgroup Contributor


My Top Tip Count:

 
Posts: n/a
Default RE: where text wraps in a cell, how can the row height be auto set

------ Register to get rid of these "In Post" ads! ------


I need to do exactly this in Excel 2007. I am not able to get the row auto
height to work. I can't even double click on the row header to make it
happen. Only dragging each individual row is working. I would greatly
appreciate some assistance getting this module to work in 2007. Thanks much!



"Greg Wilson" wrote:

> Paste the following to the worksheet's code module. The code assumes that
> each cell within A1:A10 is merged to adjacent columns as opposed to these
> cells being merged - e.g. A1:D1 are merged, A2:D2 are merged, A3:D3 are
> merged etc. Change the range reference to suit. Can be a single cell.
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> Dim NewRwHt As Single
> Dim cWdth As Single, MrgeWdth As Single
> Dim r As Range, c As Range, cc As Range
> Dim ma As Range
>
> Set r = Range("A1:A10")
> If Not Intersect(Target, r) Is Nothing Then
> Set c = Target.Cells(1, 1)
> cWdth = c.ColumnWidth
> Set ma = c.MergeArea
> For Each cc In ma.Cells
> MrgeWdth = MrgeWdth + cc.ColumnWidth
> Next
> Application.ScreenUpdating = False
> ma.MergeCells = False
> c.ColumnWidth = MrgeWdth
> c.EntireRow.AutoFit
> NewRwHt = c.RowHeight
> c.ColumnWidth = cWdth
> ma.MergeCells = True
> ma.RowHeight = NewRwHt
> cWdth = 0: MrgeWdth = 0
> Application.ScreenUpdating = True
> End If
> End Sub
>
> Alternatively, size the column width of a single cell in the same row to the
> combined column widths of the merged range. Format the font, wraptext and
> alignment exactly the same except change the font colour to be the same as
> the background (to hide it). Enter a formula that references the active cell
> of the merged range (e.g. "=C10"). Use the worksheet_change event to force
> autofit of this cell. The merged cell range will then autofit along with it.
> This assumes it is columns that are merged. Use the same logic if rows are
> merged.
>
> Regards,
> Greg
>
>
>
>
> "Stephen Sandor" wrote:
>
> > I have merged a number of cells and included text that wraps in the cell. Is
> > it possible to set the cell so that the height is automatically adjusted to
> > the height of the text?

Reply to this post


Did you find this post helpful? Yes | No
The Code Cage Advertisment
Advertisement

To stop seeing these ads and get other benefits check This page!
  #2 (permalink)  
Old 6th December 2008, 11:58 AM
Team Administrator
MS Office Version: MS Office 97, 2003, 2007
MS Office Skill Level: Proficient with most of MS Office


My Top Tip Count: 0

 
Join Date: Aug 2008
Location: Locked inside this cage
Posts: 243
Thanks to others: 0
Thanked 0 Times in 0 Posts
Rep Power: 10
The Code Cage Team will become famous soon enough
Send a message via MSN to The Code Cage Team
England
Default Re: where text wraps in a cell, how can the row height be auto set

------ Register to get rid of these "In Post" ads! ------


I'm not sure whats happened there but drop this in to the worksheet code module:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Target.Rows.EntireRow.AutoFit
End Sub
every row you click should autofit!
__________________
Regards,
The Code Cage Team
The Code Cage
Reply to this post


Did you find this post helpful? Yes | No
  #3 (permalink)  
Old 18th February 2009, 06:34 PM
Carol
Newsgroup Contributor


My Top Tip Count:

 
Posts: n/a
Default RE: where text wraps in a cell, how can the row height be auto set

------ Register to get rid of these "In Post" ads! ------


I am having the same problem. Is it an Excel 2007 glitch?
Did you find a solution that works?

THX
Carol

"Datadonna" wrote:

> I need to do exactly this in Excel 2007. I am not able to get the row auto
> height to work. I can't even double click on the row header to make it
> happen. Only dragging each individual row is working. I would greatly
> appreciate some assistance getting this module to work in 2007. Thanks much!
>
>
>
> "Greg Wilson" wrote:
>
> > Paste the following to the worksheet's code module. The code assumes that
> > each cell within A1:A10 is merged to adjacent columns as opposed to these
> > cells being merged - e.g. A1:D1 are merged, A2:D2 are merged, A3:D3 are
> > merged etc. Change the range reference to suit. Can be a single cell.
> >
> > Private Sub Worksheet_Change(ByVal Target As Range)
> > Dim NewRwHt As Single
> > Dim cWdth As Single, MrgeWdth As Single
> > Dim r As Range, c As Range, cc As Range
> > Dim ma As Range
> >
> > Set r = Range("A1:A10")
> > If Not Intersect(Target, r) Is Nothing Then
> > Set c = Target.Cells(1, 1)
> > cWdth = c.ColumnWidth
> > Set ma = c.MergeArea
> > For Each cc In ma.Cells
> > MrgeWdth = MrgeWdth + cc.ColumnWidth
> > Next
> > Application.ScreenUpdating = False
> > ma.MergeCells = False
> > c.ColumnWidth = MrgeWdth
> > c.EntireRow.AutoFit
> > NewRwHt = c.RowHeight
> > c.ColumnWidth = cWdth
> > ma.MergeCells = True
> > ma.RowHeight = NewRwHt
> > cWdth = 0: MrgeWdth = 0
> > Application.ScreenUpdating = True
> > End If
> > End Sub
> >
> > Alternatively, size the column width of a single cell in the same row to the
> > combined column widths of the merged range. Format the font, wraptext and
> > alignment exactly the same except change the font colour to be the same as
> > the background (to hide it). Enter a formula that references the active cell
> > of the merged range (e.g. "=C10"). Use the worksheet_change event to force
> > autofit of this cell. The merged cell range will then autofit along with it.
> > This assumes it is columns that are merged. Use the same logic if rows are
> > merged.
> >
> > Regards,
> > Greg
> >
> >
> >
> >
> > "Stephen Sandor" wrote:
> >
> > > I have merged a number of cells and included text that wraps in the cell. Is
> > > it possible to set the cell so that the height is automatically adjusted to
> > > the height of the text?

Reply to this post


Did you find this post helpful? Yes | No
The Code Cage Advertisment
Advertisement

To stop seeing these ads and get other benefits check This page!
  #4 (permalink)  
Old 25th February 2009, 05:47 PM
Deb
Newsgroup Contributor


My Top Tip Count:

 
Posts: n/a
Default RE: where text wraps in a cell, how can the row height be auto set

------ Register to get rid of these "In Post" ads! ------


I am having this problem, also.

Since I don't know what the "worksheet code module" is, the above does not
help me.

Need more explaination.

"Datadonna" wrote:

> I need to do exactly this in Excel 2007. I am not able to get the row auto
> height to work. I can't even double click on the row header to make it
> happen. Only dragging each individual row is working. I would greatly
> appreciate some assistance getting this module to work in 2007. Thanks much!
>
>
>
> "Greg Wilson" wrote:
>
> > Paste the following to the worksheet's code module. The code assumes that
> > each cell within A1:A10 is merged to adjacent columns as opposed to these
> > cells being merged - e.g. A1:D1 are merged, A2:D2 are merged, A3:D3 are
> > merged etc. Change the range reference to suit. Can be a single cell.
> >
> > Private Sub Worksheet_Change(ByVal Target As Range)
> > Dim NewRwHt As Single
> > Dim cWdth As Single, MrgeWdth As Single
> > Dim r As Range, c As Range, cc As Range
> > Dim ma As Range
> >
> > Set r = Range("A1:A10")
> > If Not Intersect(Target, r) Is Nothing Then
> > Set c = Target.Cells(1, 1)
> > cWdth = c.ColumnWidth
> > Set ma = c.MergeArea
> > For Each cc In ma.Cells
> > MrgeWdth = MrgeWdth + cc.ColumnWidth
> > Next
> > Application.ScreenUpdating = False
> > ma.MergeCells = False
> > c.ColumnWidth = MrgeWdth
> > c.EntireRow.AutoFit
> > NewRwHt = c.RowHeight
> > c.ColumnWidth = cWdth
> > ma.MergeCells = True
> > ma.RowHeight = NewRwHt
> > cWdth = 0: MrgeWdth = 0
> > Application.ScreenUpdating = True
> > End If
> > End Sub
> >
> > Alternatively, size the column width of a single cell in the same row to the
> > combined column widths of the merged range. Format the font, wraptext and
> > alignment exactly the same except change the font colour to be the same as
> > the background (to hide it). Enter a formula that references the active cell
> > of the merged range (e.g. "=C10"). Use the worksheet_change event to force
> > autofit of this cell. The merged cell range will then autofit along with it.
> > This assumes it is columns that are merged. Use the same logic if rows are
> > merged.
> >
> > Regards,
> > Greg
> >
> >
> >
> >
> > "Stephen Sandor" wrote:
> >
> > > I have merged a number of cells and included text that wraps in the cell. Is
> > > it possible to set the cell so that the height is automatically adjusted to
> > > the height of the text?

Reply to this post


Did you find this post helpful? Yes | No
  #5 (permalink)  
Old 25th February 2009, 08:26 PM
Dave Peterson
Newsgroup Contributor


My Top Tip Count:

 
Posts: n/a
Default Re: where text wraps in a cell, how can the row height be auto set

------ Register to get rid of these "In Post" ads! ------


If you're new to macros:

Debra Dalgleish has some notes how to implement macros here:
http://www.contextures.com/xlvba01.html

David McRitchie has an intro to macros:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Ron de Bruin's intro to macros:
http://www.rondebruin.nl/code.htm

(General, Regular and Standard modules all describe the same thing.)

Deb wrote:
>
> I am having this problem, also.
>
> Since I don't know what the "worksheet code module" is, the above does not
> help me.
>
> Need more explaination.
>
> "Datadonna" wrote:
>
> > I need to do exactly this in Excel 2007. I am not able to get the row auto
> > height to work. I can't even double click on the row header to make it
> > happen. Only dragging each individual row is working. I would greatly
> > appreciate some assistance getting this module to work in 2007. Thanks much!
> >
> >
> >
> > "Greg Wilson" wrote:
> >
> > > Paste the following to the worksheet's code module. The code assumes that
> > > each cell within A1:A10 is merged to adjacent columns as opposed to these
> > > cells being merged - e.g. A1:D1 are merged, A2:D2 are merged, A3:D3 are
> > > merged etc. Change the range reference to suit. Can be a single cell.
> > >
> > > Private Sub Worksheet_Change(ByVal Target As Range)
> > > Dim NewRwHt As Single
> > > Dim cWdth As Single, MrgeWdth As Single
> > > Dim r As Range, c As Range, cc As Range
> > > Dim ma As Range
> > >
> > > Set r = Range("A1:A10")
> > > If Not Intersect(Target, r) Is Nothing Then
> > > Set c = Target.Cells(1, 1)
> > > cWdth = c.ColumnWidth
> > > Set ma = c.MergeArea
> > > For Each cc In ma.Cells
> > > MrgeWdth = MrgeWdth + cc.ColumnWidth
> > > Next
> > > Application.ScreenUpdating = False
> > > ma.MergeCells = False
> > > c.ColumnWidth = MrgeWdth
> > > c.EntireRow.AutoFit
> > > NewRwHt = c.RowHeight
> > > c.ColumnWidth = cWdth
> > > ma.MergeCells = True
> > > ma.RowHeight = NewRwHt
> > > cWdth = 0: MrgeWdth = 0
> > > Application.ScreenUpdating = True
> > > End If
> > > End Sub
> > >
> > > Alternatively, size the column width of a single cell in the same row to the
> > > combined column widths of the merged range. Format the font, wraptext and
> > > alignment exactly the same except change the font colour to be the same as
> > > the background (to hide it). Enter a formula that references the active cell
> > > of the merged range (e.g. "=C10"). Use the worksheet_change event to force
> > > autofit of this cell. The merged cell range will then autofit along with it.
> > > This assumes it is columns that are merged. Use the same logic if rows are
> > > merged.
> > >
> > > Regards,
> > > Greg
> > >
> > >
> > >
> > >
> > > "Stephen Sandor" wrote:
> > >
> > > > I have merged a number of cells and included text that wraps in the cell. Is
> > > > it possible to set the cell so that the height is automatically adjusted to
> > > > the height of the text?


--

Dave Peterson
Reply to this post


Did you find this post helpful? Yes | No
The Code Cage Advertisment
Advertisement

To stop seeing these ads and get other benefits check This page!
Reply

Bookmarks

Tags
auto, cell, height, row, set, text, wraps

New topics in Worksheet Functions


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On

Forum Jump

The Code Cage Affilliates


To stop seeing these ads and get other benefits check This page!



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


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2
No part of this board may be copied or reproduced either in part or full without the express permission of The Code Cage Team.
We are not associated with nor employed by Microsoft in any way, we simply provide resources!
All MS office icons are registered trademarks of the application the represent