+ Reply to Thread
Results 1 to 5 of 5

Autofit didn't work to adjust row height to fit wrapped contents

  1. #1
    nwacct
    Guest

    Autofit didn't work to adjust row height to fit wrapped contents


    --
    nwacct

  2. #2
    Paul Lautman
    Guest

    Re: Autofit didn't work to adjust row height to fit wrapped contents

    nwacct wrote:

    Try this:

    Sub AutoFitMergedCellRowHeight()
    Dim CurrentRowHeight As Single, MergedCellRgWidth As Single
    Dim CurrCell As Range
    Dim ActiveCellWidth As Single, PossNewRowHeight As Single
    If ActiveCell.MergeCells Then
    With ActiveCell.MergeArea
    If .Rows.Count = 1 And .WrapText = True Then
    Application.ScreenUpdating = False
    CurrentRowHeight = .RowHeight
    ActiveCellWidth = ActiveCell.ColumnWidth
    For Each CurrCell In Selection
    MergedCellRgWidth = CurrCell.ColumnWidth +
    MergedCellRgWidth
    Next
    .MergeCells = False
    .Cells(1).ColumnWidth = MergedCellRgWidth
    .EntireRow.AutoFit
    PossNewRowHeight = .RowHeight
    .Cells(1).ColumnWidth = ActiveCellWidth
    .MergeCells = True
    .RowHeight = IIf(CurrentRowHeight > PossNewRowHeight, _
    CurrentRowHeight, PossNewRowHeight)
    End If
    End With
    End If
    End Sub



  3. #3
    nwacct
    Guest

    Re: Autofit didn't work to adjust row height to fit wrapped conten

    Thanks, Paul, but this is Greek to me - is your reply something I would paste
    somewhere in my spreadsheet or something I need to do more "globally" to the
    Excel in my PC?
    --
    nwacct


    "Paul Lautman" wrote:

    > nwacct wrote:
    >
    > Try this:
    >
    > Sub AutoFitMergedCellRowHeight()
    > Dim CurrentRowHeight As Single, MergedCellRgWidth As Single
    > Dim CurrCell As Range
    > Dim ActiveCellWidth As Single, PossNewRowHeight As Single
    > If ActiveCell.MergeCells Then
    > With ActiveCell.MergeArea
    > If .Rows.Count = 1 And .WrapText = True Then
    > Application.ScreenUpdating = False
    > CurrentRowHeight = .RowHeight
    > ActiveCellWidth = ActiveCell.ColumnWidth
    > For Each CurrCell In Selection
    > MergedCellRgWidth = CurrCell.ColumnWidth +
    > MergedCellRgWidth
    > Next
    > .MergeCells = False
    > .Cells(1).ColumnWidth = MergedCellRgWidth
    > .EntireRow.AutoFit
    > PossNewRowHeight = .RowHeight
    > .Cells(1).ColumnWidth = ActiveCellWidth
    > .MergeCells = True
    > .RowHeight = IIf(CurrentRowHeight > PossNewRowHeight, _
    > CurrentRowHeight, PossNewRowHeight)
    > End If
    > End With
    > End If
    > End Sub
    >
    >
    >


  4. #4
    Paul Lautman
    Guest

    Re: Autofit didn't work to adjust row height to fit wrapped conten

    nwacct wrote:
    > Thanks, Paul, but this is Greek to me - is your reply something I
    > would paste somewhere in my spreadsheet or something I need to do
    > more "globally" to the Excel in my PC?
    >
    >> nwacct wrote:
    >>
    >> Try this:
    >>
    >> Sub AutoFitMergedCellRowHeight()
    >> Dim CurrentRowHeight As Single, MergedCellRgWidth As Single
    >> Dim CurrCell As Range
    >> Dim ActiveCellWidth As Single, PossNewRowHeight As Single
    >> If ActiveCell.MergeCells Then
    >> With ActiveCell.MergeArea
    >> If .Rows.Count = 1 And .WrapText = True Then
    >> Application.ScreenUpdating = False
    >> CurrentRowHeight = .RowHeight
    >> ActiveCellWidth = ActiveCell.ColumnWidth
    >> For Each CurrCell In Selection
    >> MergedCellRgWidth = CurrCell.ColumnWidth +
    >> MergedCellRgWidth
    >> Next
    >> .MergeCells = False
    >> .Cells(1).ColumnWidth = MergedCellRgWidth
    >> .EntireRow.AutoFit
    >> PossNewRowHeight = .RowHeight
    >> .Cells(1).ColumnWidth = ActiveCellWidth
    >> .MergeCells = True
    >> .RowHeight = IIf(CurrentRowHeight >
    >> PossNewRowHeight, _ CurrentRowHeight,
    >> PossNewRowHeight) End If
    >> End With
    >> End If
    >> End Sub


    It is a Macro to be put into a Module



  5. #5
    nwacct
    Guest

    Re: Autofit didn't work to adjust row height to fit wrapped conten

    Thanks, again. Can't believe I would have to go to all this trouble just to
    get the row to adjust. Funny, it seems they sometimes adjust and sometimes
    don't. I'll just do it manually - don't have that many times I put that much
    in a cell.
    --
    nwacct


    "Paul Lautman" wrote:

    > nwacct wrote:
    > > Thanks, Paul, but this is Greek to me - is your reply something I
    > > would paste somewhere in my spreadsheet or something I need to do
    > > more "globally" to the Excel in my PC?
    > >
    > >> nwacct wrote:
    > >>
    > >> Try this:
    > >>
    > >> Sub AutoFitMergedCellRowHeight()
    > >> Dim CurrentRowHeight As Single, MergedCellRgWidth As Single
    > >> Dim CurrCell As Range
    > >> Dim ActiveCellWidth As Single, PossNewRowHeight As Single
    > >> If ActiveCell.MergeCells Then
    > >> With ActiveCell.MergeArea
    > >> If .Rows.Count = 1 And .WrapText = True Then
    > >> Application.ScreenUpdating = False
    > >> CurrentRowHeight = .RowHeight
    > >> ActiveCellWidth = ActiveCell.ColumnWidth
    > >> For Each CurrCell In Selection
    > >> MergedCellRgWidth = CurrCell.ColumnWidth +
    > >> MergedCellRgWidth
    > >> Next
    > >> .MergeCells = False
    > >> .Cells(1).ColumnWidth = MergedCellRgWidth
    > >> .EntireRow.AutoFit
    > >> PossNewRowHeight = .RowHeight
    > >> .Cells(1).ColumnWidth = ActiveCellWidth
    > >> .MergeCells = True
    > >> .RowHeight = IIf(CurrentRowHeight >
    > >> PossNewRowHeight, _ CurrentRowHeight,
    > >> PossNewRowHeight) End If
    > >> End With
    > >> End If
    > >> End Sub

    >
    > It is a Macro to be put into a Module
    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1