Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change from numbers to letters in Excel? 1

Status
Not open for further replies.

Zenkai

Programmer
Dec 17, 2002
31
US
I have a string of numbers that I want changed into letters in the same format as Excel's columns. I.E. if the number input is 4, I want to get "D" back. If 27, I want "AA" if 53, "BA" etc. Is there a built-in function for this, or do I need to divide by 26, get the remainder, etc.?

-Nick
 
It's not pretty, but it works:

=IF(A1>26,CHAR(INT((A1-1)/26)+64),"")&CHAR(MOD(A1-1,26)+65)
 
Question is - why would you need to? I bet that there is a more elegant solution to the UNDERLYING problem.
Rob
[flowerface]
 
Rob has a good point.

If you are trying to reference cell addresses, you may find the .Offset property useful, for example.

What is the problem you are trying to solve?
 
Yes, that's correct. I'm getting a cell address with Target.Column or ActiveCell.Column, and it returns a number. Is there a better way, to get the letters instead?
 
Oh, great! That worked like a charm :) Thanks.

Any way the address can be called without the anchors ($)?
 
Why do you need the address property? If you post a bit of your code showing what you are trying to accomplish, I bet we can help you do it.
Rob
[flowerface]
 
Zenkai:

You can use the following to return the relative address without the absolute $ designators.

Code:
expression
Code:
.Address(RowAbsolute:=False, ColumnAbsolute:=False)
Regards, LoNeRaVeR
 
Very nice. It helps to study the help file. I wonder how many more properties have parameters that extend their usefulness. (So many properties, so little time.)

Star to LoNeRaVeR
 
Sorry Rob! I'm working on the same thing I was in the other thread - I assumed you would infer that - the program to output the Excel changes to a word doc. I wanted the full formula instead of row and column.

This is going to a word doc to have a record of changes made to a workbook, and I figured the anchors would be unnecessary visual clutter. The code above worked great!

Thank-you all so much for the help, I appreciate it!

-Nick

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top