Private Sub Worksheet_Change(ByVal Target As Range)
'Modified 6/4/2019 2:14:17 AM EDT
Target.Columns.AutoFit
End Sub
Try this:
Assuming your manually entering these values
This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window
Code:Private Sub Worksheet_Change(ByVal Target As Range) 'Modified 6/4/2019 2:14:17 AM EDT Target.Columns.AutoFit End Sub
Sub AutoFit()
'Modified 6/4/2019 2:45:02 AM EDT
Application.ScreenUpdating = False
Dim r As Range
For Each r In ActiveSheet.UsedRange
r.Columns.AutoFit
Next
Application.ScreenUpdating = True
End Sub
No - it just starts with everything tight, and never expands afterwardsTry this:
Code:Sub AutoFit() 'Modified 6/4/2019 2:45:02 AM EDT Application.ScreenUpdating = False Dim r As Range For Each r In ActiveSheet.UsedRange r.Columns.AutoFit Next Application.ScreenUpdating = True End Sub
It autofits everything first (immediately after i run it), then when i input values in the worksheet it does not auto-fit anything. Your first solution will work for what I need (much appreciated), but it would be ideal if i could get it to Auto fit all the columns after every input, rather than just the column I'm inputting data into.When you run the last script I gave you it should autofit all cells on your sheet.
Are you saying the last script I sent you does nothing?
It works for me.
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified 6/4/2019 2:14:17 AM EDT
With ActiveSheet.UsedRange
.Columns.AutoFit
End With
End Sub