Auto sizing cells when opening workbook

Noob80

New Member
Joined
Dec 17, 2020
Messages
7
Office Version
  1. 365
Platform
  1. Windows
Hello,

I'm a novice at excel, trying to figure out a way to make my spreadsheet cells auto-size to show all text when I open it. I know I can click on the cell to make it auto fit but I'm trying to get a way that it just does it automatically when its opened. I have 12 columns in my spreadsheet and column "I" has way more data than any other column. I'm trying to get it so that each row will auto size to match the size of the cell in column I with all the text displaying in column "I".

Thanks
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Put this in the "ThisWorkbook" module in VBA:
VBA Code:
Private Sub Workbook_Open()
    Sheets("Sheet1").Activate
    Cells.EntireColumn.AutoFit
End Sub
and update the sheet name to reference the name of the sheet you want to apply this to (if there is only one sheet in your workbook, this line is not necessary).

This code will automatically run upon opening the workbook, provided you have VBA/Macros enabled.
 
Upvote 0
Solution
if before you save the spreadsheet you click on the square between the column and row
then goto the side of one of the columns A,B,C etc - mouse should change to a double edged arrow - double click ALL columns now autofit

i just wondered how the spreadsheet was to small when saved
But you have a VBA answer now as well
 
Upvote 0
Put this in the "ThisWorkbook" module in VBA:
VBA Code:
Private Sub Workbook_Open()
    Sheets("Sheet1").Activate
    Cells.EntireColumn.AutoFit
End Sub
and update the sheet name to reference the name of the sheet you want to apply this to (if there is only one sheet in your workbook, this line is not necessary).

This code will automatically run upon opening the workbook, provided you have VBA/Macros enabled.
Awesome! Thanks Joe. Sorry I know its been 3 years, haha. Job changed for a long time but now I'm getting back into using excel.
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,260
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top