Code to change column widths?

  • Thread starter Thread starter BABs
  • Start date Start date
B

BABs

I am running code to open a workbook and then I want to set all columns in
the workbook to 15.
I use:
..Workbooks.Open "C:\Shared\Report Info.xlsx"
..Columns.ColumnWidth = 15
This code only works on the first sheet in the workbook, but I need it to
work for all sheets.
Can someone please help me?
TIA
 
Sub tryme()
Application.ScreenUpdating = False
For Each wk In Worksheets
Columns.ColumnWidth = 15
Next
Application.ScreenUpdating = True
End Sub

best wishes
 
Ooops, many thanks for corrections
--
Bernard

Chip Pearson said:
should be
Wk.Columns.ColumnWidth = 15

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
Back
Top