(Msg. 1) Posted: Tue May 02, 2006 7:16 pm
Post subject: where text wraps in a cell, how can the row height be auto set? Archived from groups: microsoft>public>excel>worksheet>functions (more info?)
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?
(Msg. 2) Posted: Wed May 03, 2006 10:25 am
Post subject: RE: where text wraps in a cell, how can the row height be auto set? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
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?
(Msg. 3) Posted: Wed May 03, 2006 10:35 am
Post subject: RE: where text wraps in a cell, how can the row height be auto set [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
BTW, the code was adapted from an old Jim Rech post. Forgot to mention this.
Credit to him for the concept.
Greg
"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?
(Msg. 4) Posted: Fri Aug 01, 2008 8:23 am
Post subject: RE: where text wraps in a cell, how can the row height be auto set [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
Hi Greg,
Great code! Works like a charm. I found an area where this does not appear
to work. Any help you can provide would be greatly appreciated. I have an
Excel spreadsheet where information in entered in cells on one tab. Those
cells are linked to merged cells on another tab. This code does not appear
to work when applied to the merged cells that are linked. Any way around
this? Thanks,
Terry
"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?
(Msg. 5) Posted: Fri Aug 01, 2008 1:28 pm
Post subject: Re: where text wraps in a cell, how can the row height be auto set [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
If you are linking a single cell in sheet1 to a merged cell on another sheet
the single cell is not merged so Greg's code will not work on it.
Regular wrap text and autofit should work on single cells in sheet1
Gord Dibben MS Excel MVP
On Fri, 1 Aug 2008 08:23:01 -0700, Terry H. <Terry
H..TakeThisOut@discussions.microsoft.com> wrote:
>Hi Greg,
>
>Great code! Works like a charm. I found an area where this does not appear
>to work. Any help you can provide would be greatly appreciated. I have an
>Excel spreadsheet where information in entered in cells on one tab. Those
>cells are linked to merged cells on another tab. This code does not appear
>to work when applied to the merged cells that are linked. Any way around
>this? Thanks,
>
>Terry
>
>"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?
(Msg. 6) Posted: Fri Aug 01, 2008 2:16 pm
Post subject: Re: where text wraps in a cell, how can the row height be auto set [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
Thanks. That makes sense, and I can probably set things up so there is a
single cell to a single cell linkage. So I think my question is really more
about the linkage between cells instead of the merging cells.
Let's say I have a worksheet tab for data entry (sheet1) that has a cell
linked to a cell in another tab (sheet2) - one cell linking to one cell. The
destination cell (in sheet2) will not autofit to the wrapped text. Instead,
I have to manually resize the row to see all of the entered text. Is there a
way to set it up so that if data is entered into the cell in sheet1 the cell
height in sheet2 automatically expands to accommodate all of the text without
a manual adjustment?
"Gord Dibben" wrote:
> If you are linking a single cell in sheet1 to a merged cell on another sheet
> the single cell is not merged so Greg's code will not work on it.
>
> Regular wrap text and autofit should work on single cells in sheet1
>
>
> Gord Dibben MS Excel MVP
>
> On Fri, 1 Aug 2008 08:23:01 -0700, Terry H. <Terry
> H. DeleteThis @discussions.microsoft.com> wrote:
>
> >Hi Greg,
> >
> >Great code! Works like a charm. I found an area where this does not appear
> >to work. Any help you can provide would be greatly appreciated. I have an
> >Excel spreadsheet where information is entered in cells on one tab. Those
> >cells are linked to merged cells on another tab. This code does not appear
> >to work when applied to the merged cells that are linked. Any way around
> >this? Thanks,
> >
> >Terry
> >
> >"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?
>
>
(Msg. 7) Posted: Fri Aug 01, 2008 3:29 pm
Post subject: Re: where text wraps in a cell, how can the row height be auto set [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
If destination cell is set to wrap text and autofit you still have to
d-click on the bottom edge of the row header.
I don't know if the results of a formula will trigger the autofit.
Won't on my 2003 version.
Gord
On Fri, 1 Aug 2008 14:16:03 -0700, Terry H.
<TerryH.DeleteThis@discussions.microsoft.com> wrote:
>Thanks. That makes sense, and I can probably set things up so there is a
>single cell to a single cell linkage. So I think my question is really more
>about the linkage between cells instead of the merging cells.
>
>Let's say I have a worksheet tab for data entry (sheet1) that has a cell
>linked to a cell in another tab (sheet2) - one cell linking to one cell. The
>destination cell (in sheet2) will not autofit to the wrapped text. Instead,
>I have to manually resize the row to see all of the entered text. Is there a
>way to set it up so that if data is entered into the cell in sheet1 the cell
>height in sheet2 automatically expands to accommodate all of the text without
>a manual adjustment?
>
>"Gord Dibben" wrote:
>
>> If you are linking a single cell in sheet1 to a merged cell on another sheet
>> the single cell is not merged so Greg's code will not work on it.
>>
>> Regular wrap text and autofit should work on single cells in sheet1
>>
>>
>> Gord Dibben MS Excel MVP
>>
>> On Fri, 1 Aug 2008 08:23:01 -0700, Terry H. <Terry
>> H..DeleteThis@discussions.microsoft.com> wrote:
>>
>> >Hi Greg,
>> >
>> >Great code! Works like a charm. I found an area where this does not appear
>> >to work. Any help you can provide would be greatly appreciated. I have an
>> >Excel spreadsheet where information is entered in cells on one tab. Those
>> >cells are linked to merged cells on another tab. This code does not appear
>> >to work when applied to the merged cells that are linked. Any way around
>> >this? Thanks,
>> >
>> >Terry
>> >
>> >"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?
>>
>>
(Msg. 8) Posted: Sat Aug 16, 2008 6:01 pm
Post subject: Re: where text wraps in a cell, how can the row height be auto set [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
Hello
Would somebody mind to please explain this auto set row height in very
beginner terms? I am not in any way Excel Savvy. But I do have one very
simple project in Excel I am trying to complete. Very simply, I have a
"master" workbook that is to update other workbooks with exact text entered
in the master. No calculation or other fancy stuff, just the means of
entering text once and having it be copied to other workbooks. I am learning
as I go and for the most part I have a good handle on this simple process.
There are areas where an auto height adjustment of both the source field and
the targeted fields would be very useful. Cells do not need to be merged
cells. Simple copy/paste example would be greatly appreciated.
For an example that I could copy/past:
the source cell could be A19 and the target cell in a different workbook
could be B37.
Thank you for anyone who wishes to take the time to explain how this is put
into play
Nelson
"Gord Dibben" wrote:
> If destination cell is set to wrap text and autofit you still have to
> d-click on the bottom edge of the row header.
>
> I don't know if the results of a formula will trigger the autofit.
>
> Won't on my 2003 version.
>
>
> Gord
>
> On Fri, 1 Aug 2008 14:16:03 -0700, Terry H.
> <TerryH.TakeThisOut@discussions.microsoft.com> wrote:
>
> >Thanks. That makes sense, and I can probably set things up so there is a
> >single cell to a single cell linkage. So I think my question is really more
> >about the linkage between cells instead of the merging cells.
> >
> >Let's say I have a worksheet tab for data entry (sheet1) that has a cell
> >linked to a cell in another tab (sheet2) - one cell linking to one cell. The
> >destination cell (in sheet2) will not autofit to the wrapped text. Instead,
> >I have to manually resize the row to see all of the entered text. Is there a
> >way to set it up so that if data is entered into the cell in sheet1 the cell
> >height in sheet2 automatically expands to accommodate all of the text without
> >a manual adjustment?
> >
> >"Gord Dibben" wrote:
> >
> >> If you are linking a single cell in sheet1 to a merged cell on another sheet
> >> the single cell is not merged so Greg's code will not work on it.
> >>
> >> Regular wrap text and autofit should work on single cells in sheet1
> >>
> >>
> >> Gord Dibben MS Excel MVP
> >>
> >> On Fri, 1 Aug 2008 08:23:01 -0700, Terry H. <Terry
> >> H..TakeThisOut@discussions.microsoft.com> wrote:
> >>
> >> >Hi Greg,
> >> >
> >> >Great code! Works like a charm. I found an area where this does not appear
> >> >to work. Any help you can provide would be greatly appreciated. I have an
> >> >Excel spreadsheet where information is entered in cells on one tab. Those
> >> >cells are linked to merged cells on another tab. This code does not appear
> >> >to work when applied to the merged cells that are linked. Any way around
> >> >this? Thanks,
> >> >
> >> >Terry
> >> >
> >> >"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?
> >>
> >>
>
>
All times are: Eastern Time (US & Canada) (change) Goto page 1, 2, 3
Page 1 of 3
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum