Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Autofit (Columns.EntireColumn.AutoFit) does not work | Excel Discussion (Misc queries) | |||
Autofit Columns | Excel Discussion (Misc queries) | |||
autofit columns in pivot table | Excel Discussion (Misc queries) | |||
Autofit some columns | Excel Programming | |||
Columns.Autofit not doing what I want | Excel Programming |