Resize columns for all sheets in a workbook

X

Xluser@work

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.
 
N

Norman Jones

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
'<<=============
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top