excel column

Prev Next

Function Names

excel column

Description

This function converts an Excel column designtor (combination of 1-3 letters) to a column number.
Note: Excel column A translates to 0, B to 1, Z to 25, AA to 26, etc.

Call as: function

Restrictions

Indirect parameter passing is disabled

Parameter count

1

Parameters

No.TypeDescription
1
input
string Excel column specifier

Valid value are: A, B, ..., Z, AA, AB, ZZ, AAA, AAB, etc.
Do not put spaces between the letters. Letters after spaces will be ignored. Numbers (e.g. row numbers) will also be ignored.

Return value

TypeDescription
numeral Column number

Valid column numbers begin with 0. -1 is returned for invalid column specifiers, e.g. missing letters.

Examples

  for all parameters( { A, B5, Z23, AA1, ZZ, AAA, AAB, XFD, C A, '123 D', '123', ' B', '...' }, c[] )
  {
      echo(c[],": ", excel column ( c[] ) );
      // Note: -1 is returned if no appropriate letter is recognized.
  }

Output

A: 0
B5: 1
Z23: 25
AA1: 26
ZZ: 701
AAA: 702
AAB: 703
XFD: 16383
C A: 78
123 D: 3
123: -1
B: 1
...: -1
Try it yourself: Open LIB_Function_excel_column.b4p in B4P_Examples.zip. Decompress before use.