Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default AutoFit Columns in a new Worksheet

Try something like

GridSheet.UsedRange.EntireColumn.AutoFit

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Andy_WS" wrote in message
...
We had Office 2003 installed and we ran a VBscript that would auto create
workbooks depending on the data retrieved. At the bottom of the script we
used this statement:

GridSheet.Columns("A:ZZ").AutoFit ' Prettyprint


We recently upgraded to Office 2007 and the script returned a mismatch
error
when trying to AutoFit the columns. We modified the statment to this:

GridSheet.Columns("A:IV").AutoFit ' Prettyprint

If the Columns range is changed to ("A:IW") it will return a "Type
mismatch
error" again. There seems to be a limit now?

Does anyone know what has changed from 2003 to 2007 that would cause this
to
happen or does anyone know of a better way to use this statement?

Basically we want the script to AutoFit all columns contained in the
worksheet.

Thank You for your help in advance

Andy




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default AutoFit Columns in a new Worksheet

Jon,

Thank you. That worked perfectly.

Andy

"Jon Peltier" wrote:

Try something like

GridSheet.UsedRange.EntireColumn.AutoFit

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Andy_WS" wrote in message
...
We had Office 2003 installed and we ran a VBscript that would auto create
workbooks depending on the data retrieved. At the bottom of the script we
used this statement:

GridSheet.Columns("A:ZZ").AutoFit ' Prettyprint


We recently upgraded to Office 2007 and the script returned a mismatch
error
when trying to AutoFit the columns. We modified the statment to this:

GridSheet.Columns("A:IV").AutoFit ' Prettyprint

If the Columns range is changed to ("A:IW") it will return a "Type
mismatch
error" again. There seems to be a limit now?

Does anyone know what has changed from 2003 to 2007 that would cause this
to
happen or does anyone know of a better way to use this statement?

Basically we want the script to AutoFit all columns contained in the
worksheet.

Thank You for your help in advance

Andy





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
Autofit (Columns.EntireColumn.AutoFit) does not work Michiel via OfficeKB.com Excel Discussion (Misc queries) 3 February 10th 09 05:29 PM
Autofit Columns falcios Excel Discussion (Misc queries) 2 February 17th 07 04:08 PM
autofit columns in pivot table Pastel Hughes Excel Discussion (Misc queries) 2 January 5th 06 10:27 PM
Autofit some columns Me Excel Programming 2 February 20th 05 08:06 PM
Columns.Autofit not doing what I want Ed Excel Programming 2 October 25th 04 11:31 PM


All times are GMT +1. The time now is 11:46 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"