View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
jetted jetted is offline
external usenet poster
 
Posts: 1
Default Automatically fitting cell sizes to contents


Hi

To autofit any column I usually but this code in:
Open your excel spreadsheet. Go to Tools Macros Visual Basic Editor
(or you can just press Alt + F11)

On the left side is the Project Explorer. You should see something with
the name VBAProject (Name of your excel file)

Click it if it is not expanded already, and double click on Sheet1 (or
the name of your worksheet). Put the code in the box that pops up.


Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
ActiveSheet.UsedRange.Select
Selection.Columns.AutoFit
Application.EnableEvents = False
Range("a1").Select
Application.EnableEvents = True
End Sub


--
jetted
------------------------------------------------------------------------
jetted's Profile: http://www.excelforum.com/member.php...o&userid=17532
View this thread: http://www.excelforum.com/showthread...hreadid=564690