Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Autosize macro

How do I create a macro that autosizes all columns of every tab in the
workbook?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Autosize macro

The following code will autofit the columns on all worksheets:

Sub Macro1()

Dim i As Integer

For i = 1 To Sheets.Count
Sheets(i).Select
Cells.Select
Selection.Columns.AutoFit
Next i

End Sub

David


"SweetJebus" wrote in message
...
How do I create a macro that autosizes all columns of every tab in the
workbook?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Autosize macro

Hi David,

It is rarely necessary, and usually inefficient. to make selections.

To allow for possible hidden worksheets or the presence of sheets other than
worksheets, perhaps try:

'=============
Public Sub Macro1()
Dim i As Long

For i = 1 To Sheets.Count
Sheets(i).Columns.AutoFit
Next i

End Sub
'<<=============


---
Regards,
Norman


"Dove" wrote in message
...
The following code will autofit the columns on all worksheets:

Sub Macro1()

Dim i As Integer

For i = 1 To Sheets.Count
Sheets(i).Select
Cells.Select
Selection.Columns.AutoFit
Next i

End Sub

David


"SweetJebus" wrote in message
...
How do I create a macro that autosizes all columns of every tab in the
workbook?





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
autosize Learning the hard way Excel Programming 2 May 25th 06 02:16 PM
Autosize textframe Jos Vens[_2_] Excel Programming 7 November 4th 05 11:04 PM
Autosize Row Heights Andibevan Excel Discussion (Misc queries) 6 May 11th 05 01:45 PM
Macro to insert a row, copy info from another row and autosize the row Price Excel Programming 3 December 6th 03 10:15 PM
comments AutoSize CG Rosén Excel Programming 2 November 29th 03 11:20 AM


All times are GMT +1. The time now is 06:09 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"