Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
auto adjust column widths and row height | Excel Discussion (Misc queries) | |||
Setting column widths the same on multiple worksheets | Excel Discussion (Misc queries) | |||
Setting column widths when mapping out a field trial. | Excel Worksheet Functions | |||
How do I share a workbook accross the internet? | Excel Discussion (Misc queries) | |||
Share workbook accross FTP | Excel Programming |