ottopageken@gmail.com writes:
>Is there a function in JavaScript that automatically expands
>to fill in any additional columns to the right that are created?
For the following I assume the Microsoft Scripting Host
with Microsoft JScript and Microsoft Excel.
One can measure the number of filled columns extending to
the right and starting at cell »A1« using
..Cells( 1, 1 ).End( xlToRight ).Column
. So, for example, the following program prints
The extension is 6
.
var ExcelApp = new ActiveXObject( "Excel.Application" );
var ExcelSheet = new ActiveXObject( "Excel.Sheet" );
var xlToRight = -4161
ExcelSheet.ActiveSheet.Cells( 1, 1 ).Value = "This is column A, row 1";
ExcelSheet.ActiveSheet.Cells( 1, 2 ).Value = "This is column B, row 1";
ExcelSheet.ActiveSheet.Cells( 1, 3 ).Value = "This is column C, row 1";
ExcelSheet.ActiveSheet.Cells( 1, 4 ).Value = "This is column D, row 1";
ExcelSheet.ActiveSheet.Cells( 1, 5 ).Value = "This is column E, row 1";
ExcelSheet.ActiveSheet.Cells( 1, 6 ).Value = "This is column F, row 1";
WSH.echo
( "The extension is " +
ExcelSheet.ActiveSheet.Cells( 1, 1 ).End( xlToRight ).Column );
ExcelSheet.Application.Quit();