We help IT Professionals succeed at work.

# Excel API - I know row # but how to convert 52 into AZ ?

on
298 Views
I am generating an excel spreadsheet and there will be an unknown amount of columns created (decided at runtime).  I know that the last column index could be say... 63.

But I need to do a formula for the row not all, just from column 3-62.  but i can't do

formula =SUM(3:3,3:63), i have to do this:
formula =SUM(C3,BK3)  etc.

How can i convert 63 into BK (if thats what it is?) without creating a HUGE select statement ?
Comment
Watch Question

## View Solution Only

CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)

Commented:
Thanks again Bob!
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008

Commented:
Yeah, Brett, I can answer the easy ones. ;)

Bob

Commented:
i'm doing this in C# - maybe here's an easier question.. i tried to find the equivalent of Chr(3) in c# last week and couldn't find it.. do you know what it is ?

Commented:
the value of a fresh brain in the morning.  duh

convert.tochar(i);

thanks

Commented:
oh man, I am jumping the gun too much this morning.

that code didn't work :(

try passing it a value of 52, and 53.

Commented:
first col is index 1, not zero :)

public static string GetAlphaColName(int index)
{
index -= 1;
int first = (index) / 26;
int second = index % 26;
if (first > 0)
{
return Convert.ToChar(64 + first).ToString() + Convert.ToChar(65 + second).ToString();
}
else
{
return  Convert.ToChar(65 + second).ToString();
}
}
Unlock the solution to this question.

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.