Delphi code below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | function ColumnNumber(A_ColAddress: string ): Integer ; var _Digits: array of Integer ; _Pos: Integer ; _Mul, _Res: Integer ; begin SetLength(_Digits, Length(A_ColAddress)); for _Pos := 0 to Length(A_ColAddress)- 1 do begin _Digits[_Pos] := Ord(A_ColAddress[_Pos+ 1 ]) - 64 ; end ; _Mul := 1 ; _Res := 0 ; for _Pos := Length(A_ColAddress)- 1 downto 0 do begin _Res := _Res + (_Digits[_Pos] * _Mul); _Mul := _Mul * 26 ; end ; Result := _Res; end ; |