AlphaCol2Int Function
Takes a Alphabetic Column Heading like that used in MS Excel and converts it to its Numeric Equivalent.

Unit
QESBPCSConvert

Declaration
Function AlphaCol2Int(const AlphaCol: string): Word;

Description
Only at most 2 characters processed.

Parameters
AlphaCol Alphabetic Column Heading like 'A' or 'BC'

Returns
Numeric Column, where first column 'A' is 1

Category
String/Integer Conversion Routines

Implementation

function AlphaCol2Int (const AlphaCol: string): Word;
var
     LA: Integer;
     S: string;
begin
     S := UpperCase (AlphaCol);
     LA := Length (S);
     if LA = 0 then
          Result := 0
     else if LA = 1 then
          Result := Ord (S [1]) - 64
     else
          Result := (Ord (S [1]) - 64) * 26 + Ord (S [2]) - 64;
End;


HTML generated by Time2HELP
http://www.time2help.com