2.2.3.7 colmove

Menu Information

Column: Move Columns

Brief Information

Move selected columns

Command Line Usage

1. colmove rng:=col(1) operation:=last;

2. colmove rng:=col(2):col(4) operation:=first;

3. colmove rng:=col(3) operation:=left;

4. colmove rng:=col(2) operation:=right;

5. colmove rng:=col(3) operation:=pos col:=col(2);

X-Function Execution Options

Please refer to the page for additional option switches when accessing the x-function from script

Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description
Column(s) rng

Input/Output

Range

<active>

Specifies the column(s) to be moved.

Operation operation

Input

int

first

Specifies the operation to execute on the columns.
Option list

  • first:Move to First{0}
    Moves the selected columns to the first worksheet column position.
  • last:Move to Last{1}
    Moves the selected columns to the last worksheet column position.
  • right:Move Right{2}
    Moves each selected column one column to the right.
  • left:Move Left{3}
    Moves each selected column one column to the left.
  • pos:Move Before Specific Column{4}
    Moves to be before the specific column, which will be specified by the col variable.
Specific Column col

Input

Column

<unassigned>

This is only available when the operation variable is set to pos (Move Before Specific Column). It is used to specify the target column position to be moved to.

Description

This X-Function moves the specified columns to new positions in the same worksheet, allowing user to rearrange the columns.

Examples

// colmove can be used to reorder columns by moving a column left or right or to the first or last column
// Here we will reverse the order of columns ABCDE to EDCBA
newbook;
wks.ncols=5;

colmove rng:=5 operation:=first;
colmove r:=2 o:=last;
colmove r:=2 o:=right;
colmove r:=4 o:=left;
colmove r:=3 o:=left;

Related X-Functions

colswap