AutoFit Selection

  • Thread starter Thread starter Ray Batig
  • Start date Start date
R

Ray Batig

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
 
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.
 
Back
Top