Bulk Emailing

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Thursday, 6 October 2011

Excel Column Sequence Algorithm

Posted on 07:40 by Unknown
One of my friend came up with a question..."How do you find out the sequence of MS Excel column ?", lets put this in an another way, If I tell you one Excel Sheet column sequence e.g. ABA how do you find out the index of the column e.g. AA is 27th column, AB is 28th column.

So, I thought to put this as an Algo; with this if you have any sequence, you will be able to compute the column number-

Column Number = Alphabet Seq Number (right most) + Alphabet Seq Number * 26 + Alphabet Seq Number * (26*26) + .......... + Alphabet Seq Number (left most) * (p-1 times multiplication of 26)

Where,
Alphabet Seq Number = 1-26, (A = 1 and Z = 26)
p = number of Alphabets in the Column Sequence e.g. for "ABC", p = 3. Here  is C at position 1, B at 2 and A at 3.

So, with the above formula, Column number for ABC = C + B * 26 + A * (26 * 26)  
= 3 + 2 * 26 + 1* (26*26) = 731

So, what about doing the reverse i.e. generate the sequence from column number. To do this, we need to divide the number by 26 and consider the reminders to pick the Alphabet. The sequence of reminders that we get from 731 are 3 (C), 2(B), 1(A), so the Column sequence is "ABC" (last reminder value at the first).

Please find the CalculateExcelColumn.java to generate Column sequence from Column number. Hope the Algo helps...:-)
Email ThisBlogThis!Share to XShare to Facebook
Posted in | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • CityWeather
    Update: Release 1.1 has been uploaded. It will now provide weekly forecast of your selected cities. Download   CityWeather is an Android...

Blog Archive

  • ►  2013 (6)
    • ►  September (2)
    • ►  May (1)
    • ►  April (1)
    • ►  February (1)
    • ►  January (1)
  • ►  2012 (4)
    • ►  July (2)
    • ►  March (1)
    • ►  January (1)
  • ▼  2011 (11)
    • ►  November (1)
    • ▼  October (2)
      • Its about Bytes in Java
      • Excel Column Sequence Algorithm
    • ►  August (1)
    • ►  June (1)
    • ►  April (2)
    • ►  March (3)
    • ►  January (1)
  • ►  2010 (27)
    • ►  December (2)
    • ►  November (3)
    • ►  September (2)
    • ►  August (4)
    • ►  July (4)
    • ►  June (7)
    • ►  May (5)
Powered by Blogger.

About Me

Unknown
View my complete profile