Excel Sheet Column Number

Published by persolut in

Given a column title as it appears in an Excel sheet return its corresponding column number.

The number is computed in the following way:

A -> 1
B -> 2
C -> 3
...
Z -> 26
AA -> 27
AB -> 28
...

Examples

TitleToNumber("A") ➞ 1

TitleToNumber("R") ➞ 18

TitleToNumber("AB") ➞ 28

Notes

  • 1 <= len(str) <= 7
  • str consists only of uppercase English letters.
Watch a quick demo on how Edabit works.