1

According to this topic: How to convert a column number (e.g. 127) into an excel column (e.g. AA)

I don't understand what is in algorithm: here

Could someone explain me, what is happening in a while loop?

Community
  • 1
  • 1
Prezes Łukasz
  • 938
  • 1
  • 9
  • 30

1 Answers1

1

It is, in effect, "converting" the column number to base 26, where the "digits" are the letters A..Z.

For example, for column 720:

  • modulo = (720-1)%26 = 17
  • columnName = 'R'
  • dividend = (720-17)/26 = 27
  • modulo = (27-1)%26 = 0
  • columnName = A+columnName = AR
  • dividend = (27-0)/26 = 1
  • modulo = (1-1)%26 = 0
  • columnName = A + columnName = AAR
  • dividend = (1-0)/26 = 0

Resulting in AAR.

Scott Hunter
  • 48,888
  • 12
  • 60
  • 101