Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Resize columns for all sheets in a workbook

I am trying to resize the columns in all sheets of a workbook and I have a
number of workbooks each with a different number of sheets.

The code I have so far is:

For Each Worksheet In ActiveWorkbook.Worksheets
Columns("A:A").EntireColumn.ColumnWidth = 30.71
Columns("B:B").EntireColumn.ColumnWidth = 8.57
Columns("C:C").EntireColumn.ColumnWidth = 8.57
Columns("D:D").EntireColumn.ColumnWidth = 8.57
Columns("E:E").EntireColumn.ColumnWidth = 8.57
Columns("F:F").EntireColumn.ColumnWidth = 8.57
Columns("G:G").EntireColumn.ColumnWidth = 2.14
Columns("H:H").EntireColumn.ColumnWidth = 8.57
Columns("I:I").EntireColumn.ColumnWidth = 8.57
Columns("J:J").EntireColumn.ColumnWidth = 8.57
Columns("K:K").EntireColumn.ColumnWidth = 8.57
Columns("L:L").EntireColumn.ColumnWidth = 8.57
Next Worksheet
End Sub

It appears to iterate through each worksheet based on display update but
only corrects the column widths on the active sheet at the time the code is
run. Can anyone advise how I force the code to carry out the instruction on
each sheet?

Thanks for any help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Resize columns for all sheets in a workbook

Hi XlUser,

Try:

'=============
Public Sub Tester()
Dim SH As Worksheet

For Each SH In ActiveWorkbook.Worksheets
With SH
.Columns("A:A").EntireColumn.ColumnWidth = 30.71
.Columns("B:F").EntireColumn.ColumnWidth = 8.57
.Columns("G:G").EntireColumn.ColumnWidth = 2.14
.Columns("H:L").EntireColumn.ColumnWidth = 8.57
End With
Next SH
End Sub
'<<=============


--
---
Regards,
Norman



"Xluser@work" wrote in message
...
I am trying to resize the columns in all sheets of a workbook and I have a
number of workbooks each with a different number of sheets.

The code I have so far is:

For Each Worksheet In ActiveWorkbook.Worksheets
Columns("A:A").EntireColumn.ColumnWidth = 30.71
Columns("B:B").EntireColumn.ColumnWidth = 8.57
Columns("C:C").EntireColumn.ColumnWidth = 8.57
Columns("D:D").EntireColumn.ColumnWidth = 8.57
Columns("E:E").EntireColumn.ColumnWidth = 8.57
Columns("F:F").EntireColumn.ColumnWidth = 8.57
Columns("G:G").EntireColumn.ColumnWidth = 2.14
Columns("H:H").EntireColumn.ColumnWidth = 8.57
Columns("I:I").EntireColumn.ColumnWidth = 8.57
Columns("J:J").EntireColumn.ColumnWidth = 8.57
Columns("K:K").EntireColumn.ColumnWidth = 8.57
Columns("L:L").EntireColumn.ColumnWidth = 8.57
Next Worksheet
End Sub

It appears to iterate through each worksheet based on display update but
only corrects the column widths on the active sheet at the time the code
is
run. Can anyone advise how I force the code to carry out the instruction
on
each sheet?

Thanks for any help.



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
In need to link Columns between sheets of a workbook? SkyscraperCM Excel Discussion (Misc queries) 2 December 12th 08 12:49 AM
how to resize columns without affecting columns above? ggault New Users to Excel 1 November 25th 08 08:28 PM
How can I resize columns within one row only? Hannah Excel Discussion (Misc queries) 1 March 26th 08 09:08 PM
comparing 2 similar columns on seperate work sheets in 1 workbook Dan Excel Discussion (Misc queries) 4 September 20th 05 11:58 PM
Can Columns Resize Automatically??? Todd Huttenstine\(Remote\) Excel Programming 3 November 30th 03 09:41 AM


All times are GMT +1. The time now is 01:41 PM.

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"