The colnum(colNameOrDs) function returns the column position number of the column specified by colName.

Note: The argument for this function can also be a dataset name. For example, Book1_B or Book1_B@2 (for a dataset in a workbook). When supplying a workbook dataset name as the argument, the dataset need not be in the active workbook sheet. It also need not be in the active workbook. If the dataset exists in a workbook that isn't active, this function sets the associated workbook layer active but doesn't set the workbook active.


The following script sets Variable to 2 if column B is the second column of the current worksheet.

Variable = ColNum(B);

See Also:

NameOf (function)

Range2uid (function)

Uid2range (function)

Uid2name (function)