Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11
Default Autofit and merge

I am sure there is a simple answer out there...
I am using Excel to create a kind of workbook for my users to fill
in...because I have a few lists with checkboxes, there are columns of varying
width - after all the basic info such as name, date, project, etc is filled
in and the various boxes checked, there are some areas for comments. To
create a more appealing layout, I merged a number of cells so text would
cross the page. The problem is when I tried to use Autofit to allow the
merged cells to expand as text was entered - it didn't work...
If I unmerge the cells,it works fine...
If I enter text text and use autofit first, then merge the cells, it also
seems to work..
But neither are acceptable solutions...
I should be able to create a nice layout and my users should be able to just
enter text and have the rows adjust as they type...
Help....
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Autofit and merge

Long audible sigh here.................

One more victim of "merged cells".

Wrap Text works fine on merged cells, but Autofit does not work.

You need VBA code to do that.

Here is code from Greg Wilson.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim NewRwHt As Single
Dim cWdth As Single, MrgeWdth As Single
Dim c As Range, cc As Range
Dim ma As Range

With Target
If .MergeCells And .WrapText 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 With
End Sub


Gord Dibben MS Excel MVP

On Wed, 23 Aug 2006 12:51:04 -0700, Nimbus55
wrote:

I am sure there is a simple answer out there...
I am using Excel to create a kind of workbook for my users to fill
in...because I have a few lists with checkboxes, there are columns of varying
width - after all the basic info such as name, date, project, etc is filled
in and the various boxes checked, there are some areas for comments. To
create a more appealing layout, I merged a number of cells so text would
cross the page. The problem is when I tried to use Autofit to allow the
merged cells to expand as text was entered - it didn't work...
If I unmerge the cells,it works fine...
If I enter text text and use autofit first, then merge the cells, it also
seems to work..
But neither are acceptable solutions...
I should be able to create a nice layout and my users should be able to just
enter text and have the rows adjust as they type...
Help....


Gord Dibben MS Excel MVP
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11
Default Autofit and merge

Ok..this worked! Now I hope it doesn't flip SharePoint out and fail utterly
like so many others have...lol. So far, VB code in any workbook I open from
SharePoint is autmatcialy disabled by "security" and I have to add yet more
freakin' code to get around it...grrrr. How is it that Sharepoint, a MS
product is NOT compatible with Excel..another MS product???
Anyway...Gord, thanks for yoru help; Greg ,thanks for the code.


"Gord Dibben" wrote:

Long audible sigh here.................

One more victim of "merged cells".

Wrap Text works fine on merged cells, but Autofit does not work.

You need VBA code to do that.

Here is code from Greg Wilson.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim NewRwHt As Single
Dim cWdth As Single, MrgeWdth As Single
Dim c As Range, cc As Range
Dim ma As Range

With Target
If .MergeCells And .WrapText 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 With
End Sub


Gord Dibben MS Excel MVP

On Wed, 23 Aug 2006 12:51:04 -0700, Nimbus55
wrote:

I am sure there is a simple answer out there...
I am using Excel to create a kind of workbook for my users to fill
in...because I have a few lists with checkboxes, there are columns of varying
width - after all the basic info such as name, date, project, etc is filled
in and the various boxes checked, there are some areas for comments. To
create a more appealing layout, I merged a number of cells so text would
cross the page. The problem is when I tried to use Autofit to allow the
merged cells to expand as text was entered - it didn't work...
If I unmerge the cells,it works fine...
If I enter text text and use autofit first, then merge the cells, it also
seems to work..
But neither are acceptable solutions...
I should be able to create a nice layout and my users should be able to just
enter text and have the rows adjust as they type...
Help....


Gord Dibben MS Excel MVP

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
How to make (XL) Merge Cells and Word Wrap work concurrently? George D. Excel Discussion (Misc queries) 1 May 2nd 06 05:41 PM
Autofit doesn't work with merged cells Jen_G Excel Discussion (Misc queries) 3 January 30th 06 09:57 PM
Autofit row height in merged cells BobT Excel Discussion (Misc queries) 1 February 25th 05 04:44 PM


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