![]() |
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. |
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. |
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 |
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 |
All times are GMT +1. The time now is 04:19 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com