PC Review


Reply
Thread Tools Rate Thread

Code to change column widths?

 
 
BABs
Guest
Posts: n/a
 
      18th Feb 2009
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
 
Reply With Quote
 
 
 
 
Bernard Liengme
Guest
Posts: n/a
 
      18th Feb 2009
Sub tryme()
Application.ScreenUpdating = False
For Each wk In Worksheets
Columns.ColumnWidth = 15
Next
Application.ScreenUpdating = True
End Sub

best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"BABs" <(E-Mail Removed)> wrote in message
news:B5B550DE-8EBC-437F-BC0E-(E-Mail Removed)...
>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



 
Reply With Quote
 
Chip Pearson
Guest
Posts: n/a
 
      18th Feb 2009

> Columns.ColumnWidth = 15

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)

On Wed, 18 Feb 2009 10:14:43 -0400, "Bernard Liengme"
<(E-Mail Removed)> wrote:

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

 
Reply With Quote
 
Bernard Liengme
Guest
Posts: n/a
 
      18th Feb 2009
Ooops, many thanks for corrections
--
Bernard

"Chip Pearson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
>> Columns.ColumnWidth = 15

> 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)
>
> On Wed, 18 Feb 2009 10:14:43 -0400, "Bernard Liengme"
> <(E-Mail Removed)> wrote:
>
>>Sub tryme()
>> Application.ScreenUpdating = False
>> For Each wk In Worksheets
>> Columns.ColumnWidth = 15
>> Next
>> Application.ScreenUpdating = True
>>End Sub
>>
>>best wishes



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
listbox - code to adjust column widths Roger on Excel Microsoft Excel Programming 4 29th Nov 2009 02:49 AM
Automatically change column widths? =?Utf-8?B?Um9zcw==?= Microsoft Excel Misc 2 20th Jul 2007 07:58 PM
Re: Why do column widths change in Excell? huntnpeck Microsoft Excel Worksheet Functions 0 13th Jan 2007 07:08 PM
setting datagrid column widths in code? =?Utf-8?B?UmljaA==?= Microsoft VB .NET 4 27th Jan 2006 08:19 PM
change column widths w/o affecting rows above =?Utf-8?B?TWlrZSBH?= Microsoft Excel Misc 2 26th Nov 2003 09:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:15 PM.