ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   AutoFit Selection (https://www.excelbanter.com/excel-programming/286082-autofit-selection.html)

Ray Batig

AutoFit Selection
 
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



J.E. McGimpsey

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




All times are GMT +1. The time now is 10:04 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com