Convert Excel column letter to index

Hi,

I need to convert excel column letter to index value. suppose column letter is AA, index value should be 27.

Some code here will help.

Hi @reshmaprabh

Check this code

colName = "AA" 
result = colName.Select(Function(c, i) ((Convert.ToInt32(c) - Convert.ToInt32("A"c) + 1) * (CInt(Math.Pow(26, colName.Length - i - 1))) )).Sum()
4 Likes

Refer this also.! @reshmaprabh

Thanks!

1 Like

I got the solution. Thanks everyone…:slight_smile:

columnLetter = columnLetter.ToUpper()
sum=0
For i As Integer = 0 To columnLetter.Length-1
sum *= 26
Dim charA As Double = Asc(“A”)

    Dim charColLetter As Double = Asc(columnLetter(i))
   
    sum += (charColLetter - charA) + 1
   
Next
2 Likes

You could also use this snippet from the marketplace:
https://go.uipath.com/component/convert-numbers-to-excel-column-name

Or take a look into this solution from @Palaniyappan

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.