Macro command Copy

<< Click to Display Table of Contents >>

Navigation:  Macros > Macro commands and parameters > Macro reporting commands > Macro write to Excel >

Macro command Copy

Purpose:

to copy a range of cells of a worksheet into a worksheet of the output workbook

 

General notation:

Copy( FileIndex, SheetA, Row1, Column1, Row2, Column2, SheetB, Row3, Column3 )

 

FileIndex is the same index used by the Open command. Using the Open command a spreadsheet file is assigned to a FileIndex for later Read commands. The FileIndex is an integer number between 1 and 9. If a value of 0 is assigned to the FileIndex, this corresponds to the currently opened output spreadsheet.

The result will always be copied into the output spreadsheet (with FileIndex number 0).

 

The worksheet cell can be accessed by its row and colum number. The normal Excel notation (identification of a cell by means of a combination of letters and numbers) is not possible because the macro language works on a numeric basis.

 

SheetA : the worksheet where has to be copied from
Row1: 'from' cells range upper left corner row number
Column1: 'from' cells range upper left corner column number
Row2: 'from' cells range lower right corner row number  
Column2: 'from' cells range lower right corner column number
SheetB: the worksheet in the output spreadsheet where has to be copied to
Row3: 'to' cells range upper left corner row number
Column3: 'to' cells range upper left corner column number

 

Example:

Copy the cells range A2 .. C9 on Sheet1 of spreadsheet with FileIndex 1 to the output spreadsheet, Sheet2 on position G6:

 Set( FileIndex, 1 )

 Set( SheetA, 1 )

 Set( Row1, 2 )

 Set( Column1, 1 )

 Set( Row2, 9 )

 Set( Column2, 3 )

 Set( SheetB, 2 )

 Set( Row3, 6 )

 Set( Column3, 7 )

 Copy( FileIndex, SheetA, Row1, Column1, Row2, Column2, SheetB, Row3, Column3 )

 

Or simply:

 Copy( 1, 1, 2, 1, 9, 3, 2, 6, 7 )