Merged fields in Excel don't stretch to fit the text

Anonymous
2015-01-12T15:41:01+00:00

Hi

I have an excel 2010 spreadsheet that I use to Macro out certain sheets into its own file and within that sheet I have 3 columns but some of the rows are merged across those 3 columns.  When I macro out the row does not auto fit the text because it is merged.  Is there anything I can add within my macro to automatically get the row to fit the text?

Thanks

Micheemoo

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
Answer accepted by question author
Anonymous
2015-01-13T15:54:25+00:00

What I posted is worksheet event code.

Right-click on the sheettab and select "View Code"

Paste the code as is into that module.

Return to the sheet and make sure merged cells are formatted to wrap text.

When you type text into a merged cell then hit Enter the autofit will take place.

If you already have text in a cell you can F2>Enter to trigger the code.

Gord

Was this answer helpful?

0 comments No comments

10 additional answers

Sort by: Most helpful
  1. Anonymous
    2015-02-03T21:43:56+00:00

    To get existing cells with text to autofit you must trigger an event in that cell.

    That is what the F2>Enter does.

    The code is suited to autofitting when you type new text into a cell.

    Gord

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2015-02-03T20:11:44+00:00

    What I posted is worksheet event code.

    Right-click on the sheettab and select "View Code"

    Paste the code as is into that module.

    Return to the sheet and make sure merged cells are formatted to wrap text.

    When you type text into a merged cell then hit Enter the autofit will take place.

    If you already have text in a cell you can F2>Enter to trigger the code.

    Gord

    Hi again Gord

    I added the code in and when I macro out it doesn't autofit the cells but if I press F2 that makes it fit if I put the cursor in the relevant cell - but is there anyway to automate the F2 part??

    The reason I ask is I have a user who has not used excel very much and I am trying to automate as many of my processes as possible.

    Thanks

    Michelle

    Was this answer helpful?

    0 comments No comments