#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Autofit

If I'm in an Excel spreadsheet I can click the button between column label A
and row label 1 to select the entire worksheet. Then I can double click in
between any column and all the columns will autofit to the best fit. How can
achieve this affect using VBA code?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Autofit

This is exactly what you get when you use the macro recorder.

Sub fit()
Cells.Select
Selection.Columns.AutoFit
End Sub


Gord Dibben MS Excel MVP

On Tue, 27 Apr 2010 16:11:01 -0700, Bishop
wrote:

If I'm in an Excel spreadsheet I can click the button between column label A
and row label 1 to select the entire worksheet. Then I can double click in
between any column and all the columns will autofit to the best fit. How can
achieve this affect using VBA code?


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Rows().AutoFit starts a calculation, but Columns().AutoFit doesn't Stefano[_2_] Excel Programming 1 November 30th 09 05:01 PM
Rows().AutoFit starts a calculation, but Columns().AutoFit doesn't Mike H Excel Programming 0 November 25th 09 04:31 PM
Autofit Jess Excel Programming 2 September 25th 09 01:49 AM
Autofit (Columns.EntireColumn.AutoFit) does not work Michiel via OfficeKB.com Excel Discussion (Misc queries) 3 February 10th 09 05:29 PM
autofit does not autofit rreneerob Excel Discussion (Misc queries) 1 October 17th 05 05:55 PM


All times are GMT +1. The time now is 06:39 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"