Planning Analyst Add-in for Microsoft Excel User Guide  10.1.0
Macros, Assigning Actions, D-Links >

Visual Basic Commands

The following Microsoft® Visual Basic commands can be used in Microsoft Excel macros. The exact syntax may vary depending on your version of Excel.

Example

Description

Workbooks.Open "C:\Test\Test.xls"

Open an Excel file

Sheets("Sheet1").Select

Make Sheet1 the active sheet

Range("A1").Select

Make A1 the active cell

ActiveCell.Value="99"

Set the contents of the active cell to 99

For i = 1 to 3 Sheets(i).PrintOut Next i

Print sheets 1 to 3

For i = 3 To 1 Step -1 Sheets(i).PrintOut Next i

Print sheets 1 to 3 in reverse print order

You can continue long lines by ending them with a space and an underscore character. You can put comments in by preceding them with a single quote character.

Example Macro 2:

This macro opens another Excel file and print sheets 1 to 3 in reverse print order.

Macro1 Macro Sub Macro1() Workbooks.Open "c:\test\test.xls" For i = 3 To 1 Step -1 Sheets(i).Select Sheets(i).PrintOut Next i End