In Excel VBA - programmatically select entire spreadsheet and perform AUTOFIT

Tom Knowlton
Tom Knowlton used Ask the Experts™
on
In Excel VBA, how do I programmatically select entire spreadsheet and perform AUTOFIT on the columns?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2006
Commented:
something like running this sub

Sub AutoFitAll()
Dim sh
  For Each sh In ThisWorkbook.Sheets
    sh.Cells.Columns.AutoFit
  Next
End sub
Suat OzgurWeb / Application Developer
Commented:
Activesheet.Columns.AutoFit

or

Sheets("Sheet1").AutoFit

Suat

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial