Stop column resizing madness

drpdrpdrp

New Member
Joined
Sep 9, 2021
Messages
20
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

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
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 0
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,214,983
Messages
6,122,582
Members
449,089
Latest member
Motoracer88

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