Stop column resizing madness

drpdrpdrp

New Member
Joined
Sep 9, 2021
Messages
22
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
I do not like Excel's default behavior of:

  • expanding a column width if a large number is typed/returned for the first time
  • not resizing if a large number is typed/returned, if it has been already resized
  • not resizing if a large character string is entered ("spill" contents)
Seems like a workaround would be to resize all columns (for the "first time") before working in a sheet. I would expect something like:
VBA Code:
Sub columnWidth()
    Range("A:XFD").columnWidth = 8.5
End Sub

to work, but it does not. Any suggestions?
To be clear, what I am trying to achieve is: a vba sub that I can run before I start to work on a sheet that will prevent any *automatic* width and height adjustments
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Try this

VBA Code:
Sub PreventAutomaticAdjustments()
    With Application
        .AutomationSecurity = msoAutomationSecurityForceDisable
        .ScreenUpdating = False
        .Calculation = xlCalculationManual
        .EnableEvents = False
    End With
End Sub
VBA Code:
Private Sub Workbook_Open()
    Call PreventAutomaticAdjustments
End Sub
 
Upvote 0
It might be a good idea if you explain exactly what that code does, as it could easily cause problems.
 
Upvote 1
Try this

VBA Code:
Sub PreventAutomaticAdjustments()
    With Application
        .AutomationSecurity = msoAutomationSecurityForceDisable
        .ScreenUpdating = False
        .Calculation = xlCalculationManual
        .EnableEvents = False
    End With
End Sub
VBA Code:
Private Sub Workbook_Open()
    Call PreventAutomaticAdjustments
End Sub
Thanks. Any chance you could explain why this code will prevent the column width to resize based on cell contents?
 
Upvote 0
Fraid not. I not sure it's even possible.
 
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,191
Members
453,021
Latest member
pingpong7117

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