• Home
  • Blog
  • Resume
  • Contact
  • Projects
  • Gallery
  • Amit’s Resume
  • About Nagpur
KEEP IN TOUCH

Convert a number to its equivalent letter

Dec17
2005
2 Comments Written by admin

If you want to convert a number to its equivalent letter, for e.g. 5 to E, you can use two approaches.

1. Insert this code in a Module and use this function

‘Author: Alan L. Lesmerises
‘From: http://www.freevbcode.com/ShowCode.asp?ID=4303

Function ColumnLetter(ColumnNumber As Integer) As String
  If ColumnNumber > 26 Then

    ‘ 1st character:  Subtract 1 to map the characters to 0-25,
    ‘                 but you don’t have to remap back to 1-26
    ‘                 after the ‘Int’ operation since columns
    ‘                 1-26 have no prefix letter

    ‘ 2nd character:  Subtract 1 to map the characters to 0-25,
    ‘                 but then must remap back to 1-26 after
    ‘                 the ‘Mod’ operation by adding 1 back in
    ‘                 (included in the ’65′)

    ColumnLetter = Chr(Int((ColumnNumber – 1) / 26) + 64) & _
                   Chr(((ColumnNumber – 1) Mod 26) + 65)
  Else
    ‘ Columns A-Z
    ColumnLetter = Chr(ColumnNumber + 64)
  End If
End Function

e.g. “=Columnletter(5)” will return E and “= Columnletter(COLUMN())” will return letter depending on which column this formula is in.

2. Use this formula (Credit due) “=LEFT(ADDRESS(1,COLUMN(),4),1)”

These formulas can be useful with functions like INDIRECT and OFFSET.

Related posts:

  1. Importing IE bookmark
  2. String Operations
Posted in Uncategorized - Tagged ID, INDIRECT, OFFSET
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail
« Excel 12 will have lots of columns and rows…
» Stack Columns of Data on one column

2 Comments

  1. Anonymous's Gravatar Anonymous
    May 5, 2008 at 1:40 pm | Permalink

    Perfect Function , Exaclty what i needed!!!! Dalik

  2. 7th-key's Gravatar 7th-key
    September 19, 2008 at 9:50 am | Permalink

    Thank you!

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

*

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Tags

Access Alt F8 Books boxplot cells charts count cursor dashboard data mining dbase design error excel excel functions export filter flip LaTex MS query Number Err ODBC pipes Press Alt F11 Public Sub python R random numbers Range Cells report scripting software sparklines SQL SQL server stack columns statistics stemming string tag cloud text mining UDF VBA visualization wildcard

Network

View Ashutosh Nandeshwar's profile on LinkedIn

Recent Comments

  • W. McNabb on The search key was not found in any record in Access
  • Manuel on The search key was not found in any record in Access
  • Wendy Naples on The search key was not found in any record in Access
  • larry on Access Export to Excel (2007)
  • Betty Chou on Projects

Related Posts

  1. Importing IE bookmark
  2. String Operations

EvoLve theme by Blogatize  •  Powered by WordPress nandeshwar.info