Code to change column widths?

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
 
B

Bernard Liengme

Sub tryme()
Application.ScreenUpdating = False
For Each wk In Worksheets
Columns.ColumnWidth = 15
Next
Application.ScreenUpdating = True
End Sub

best wishes
 
B

Bernard Liengme

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)
 

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