How To Make Excel Cells Expand To Fit Text Automatically

In this article, I will show you how to make an excel cell expand it’s width and height to fit the input text width or height automatically.

1. Make Excel Cell Expand To Fit Text Size Method 1.

  1. Put the mouse pointer at the cell’s column heading right border or row heading lower border that you want to expand.
  2. When the mouse pointer change to a left-right or up-down arrow, double click it.
  3. Then you can find the cell has been expanded to fit the text size.

2. Make Excel Cell Expand To Fit Text Size Method 2.

  1. Select the excel cell that you want to expand to fit the text size.
  2. Click Home —> Format —> AutoFit Row Height / AutoFit Column Width menu item to expand it.
  3. The above menu item has a shortcut key that is Alt + H( Home tab) + O ( Format menu ) + A ( AutoFit Row Height ) / I (AutoFit Column Width)

3. Expand Multiple Excel Cell To Fit Text.

  1. Sometimes you need to expand multiple excel cells to make them fit the text content, you can follow the below steps to do it.
  2. Select multiple columns or rows.
  3. Or press Ctrl + A to select the whole excel worksheet.
  4. Then you can follow method 1 or 2 to expand all the columns or rows.

4. How To Make An Excel Cell Wrap Text Content Automatically.

  1. In Microsoft Excel, you can make an Excel cell wrap it’s content automatically so that it will display multiple lines of the cell content in the cell.
  2. You can even enter a line-break manually to separate the different textual content in an Excel cell.
  3. To do this, you need to first select the cells, then click the Home(tab) —> Alignment(group) —> Wrap Text item.
  4. The above action also has a shortcut key that is Alt + H + W.
  5. Now the cell will wrap its text data to match the column width change automatically, when you drag the edge of the Excel cell to increase/decrease its width, the text line in it will automatically adjust its length also.

5. How To Input Line Break In One Excel Cell To Input Text In A New Line.

  1. You can input a line break to enter the text in a new line in an excel cell following the below steps.
  2. Select the Excel cell by double click it.
  3. Click the position that you want to enter a new line break.
  4. Press shortcut Alt + Enter, then you can input text in the next new line after the current position.

6. How To Make Text Auto Fit Excel Cell’s Width & Height Programmatically In C#.

6.1 Question1.

  1. I write a c# program, in that program, it will read data from a SQL Server database table, and then write the data to a .csv file. The c# source code is sw.Write(string.Format(“=\”{0}\””, drow[i].ToString()));.
  2. But when I open the .csv file in Microsoft Excel, I find the table data in the excel cell is not auto-fit the width & height of the cell.
  3. How can I make the text data auto-fit the excel cell width & height programmatically? I use c# language, thanks a lot.

6.2 Answer1.

  1. You can first load your .csv file into an instance of Microsoft.Office.Interop.Excel.
  2. Then run the code Excel.Rows.AutoFit (Range.Rows.AutoFit()) to auto fit the height.
  3. And run the code Excel.Columns.AutoFit (Range.Columns.AutoFit()) to auto fit the width.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.