GET IN TOUCH:(213) 537 - 3054
610 S. Broadway Suite 1001 Los Angeles, CA 90014

IT service, Computer Repair


How to Use AutoFit to Adjust Cells in Excel

Introduction

In Microsoft Excel, cell sizes do not always adjust automatically to fit the data you enter. This can cause text, numbers, or headings to appear cut off or hidden within a cell. The AutoFit feature solves this problem by automatically resizing rows or columns so that all the content is fully visible without manual adjustments. With just a few clicks, AutoFit ensures that your worksheet remains neat, organized, and easy to read.

Instruction

  • Step 1: Open Exce
    Open the Excel workbook where you want to autofit columns.
  • Step 2: Open the VBA Editor
    1. Press Alt + F11 on your keyboard to open, This opens the Visual Basic for Applications (VBA) editor
     2. on the left side, right click the sheet you want to modify and click on View Code.
     3. from the top drop down list select "Worksheet"
     4. insert below code:
    
    	Cells.EntireColumn.AutoFit
    
     inside this block of code:
                
     Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
      Cells.EntireColumn.AutoFit
    End Sub "X" out of Visual basic and save your excel file as .xlsm, Excel Macro-Enabled Workbook.
tsc n-able