View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
J.E. McGimpsey J.E. McGimpsey is offline
external usenet poster
 
Posts: 493
Default AutoFit Selection

one way:

Range(Cells(4, 5), Cells(4, Columns.Count).End( _
xlToLeft)).EntireColumn.Autofit

By finding the first filled cell to the left of cell IV4, we avoid
the loop.


In article . net,
"Ray Batig" wrote:

I the Format Column drop down is a choice called 'AutoFit Selection'. How
would you call this function from a macro? What I want to do is two fold. 1.
Start at a cell such as cell(4,5) and go to the right most cell with an
entry and resize each column as you pass over the cell. 2. Start at the
same example cell and go down the column find the longest cell and then
call the 'AutoFit Selection' to resize the column.


Thanks for explaining this feature.

Ray