Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Auto setting column widths accross a whole workbook


I was trying to write a macro to select all columns on all sheets in
the workbook and force the columns to fit to the data. However, even
using a tip here to select all the sheets, I could only get it to apply
automatic widths to the current sheet.

Is it possible to write a macro to do this?

Any help apreciated. Excel 2003.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Auto setting column widths accross a whole workbook

Hi Vmaster
Try ou this

Sub AutoFitColumns()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Columns.AutoFit
Next
End Sub




"vMaster" wrote:


I was trying to write a macro to select all columns on all sheets in
the workbook and force the columns to fit to the data. However, even
using a tip here to select all the sheets, I could only get it to apply
automatic widths to the current sheet.

Is it possible to write a macro to do this?

Any help apreciated. Excel 2003.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Auto setting column widths accross a whole workbook

For some reason this did nothing! Is 'ThisWorkbook' proper syntax?

Anyway this did work, not really sure what the difference with! I got
there with your help. Thanks!

Sub Autowidth()
'
' Autowidth Macro
' Macro recorded 26/12/2005 by
'
'
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Columns.AutoFit
Next
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Auto setting column widths accross a whole workbook

HI Vmaster,
Thisworkbook refers to the workbook on which you have written the
function,and active workbook refers to the workbook which is active now

Thanks
Xcelion



"vMaster" wrote:

For some reason this did nothing! Is 'ThisWorkbook' proper syntax?

Anyway this did work, not really sure what the difference with! I got
there with your help. Thanks!

Sub Autowidth()
'
' Autowidth Macro
' Macro recorded 26/12/2005 by
'
'
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Columns.AutoFit
Next
End Sub


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
auto adjust column widths and row height DebC Excel Discussion (Misc queries) 1 November 24th 09 03:17 PM
Setting column widths the same on multiple worksheets John Excel Discussion (Misc queries) 2 April 19th 08 04:00 PM
Setting column widths when mapping out a field trial. Candys Kisses Excel Worksheet Functions 1 August 21st 07 12:12 AM
How do I share a workbook accross the internet? ryan Excel Discussion (Misc queries) 0 January 7th 06 05:32 PM
Share workbook accross FTP steven knight Excel Programming 0 September 9th 04 10:52 AM


All times are GMT +1. The time now is 02:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"