converts the Integer to a String representation of the same column. : Column « Excel « VBA / Excel / Access / Word

VBA / Excel / Access / Word
1. Access
2. Application
3. Data Type
4. Data Type Functions
5. Date Functions
6. Excel
7. File Path
8. Forms
9. Language Basics
10. Math Functions
11. Outlook
12. PowerPoint
13. String Functions
14. Windows API
15. Word
16. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
VBA / Excel / Access / Word » Excel » Column 
converts the Integer to a String representation of the same column.
 
Sub Main()
   Debug.Print GetColumnRef(3)
End Sub

Function GetColumnRef(columnIndex As IntegerAs String
    Dim numAlpha As Integer
    Dim firstLetter As String
    Dim secondLetter As String
    Dim remainder As Integer

    numAlpha = columnIndex \ 26
    Select Case columnIndex / 26
        Case Is <= 1      'Column ref is between A and Z
            firstLetter = Chr(columnIndex + 64)
            GetColumnRef = firstLetter
        Case Else      'Column ref has two letters
            remainder = columnIndex - 26 (columnIndex \ 26)
            If remainder = Then
                firstLetter = Chr(64 (columnIndex \ 261)
                secondLetter = "Z"
                GetColumnRef = firstLetter & secondLetter
            Else
                firstLetter = Chr(64 (columnIndex \ 26))
                secondLetter = Chr(64 + remainder)
                GetColumnRef = firstLetter & secondLetter
            End If
    End Select
End Function

 
Related examples in the same category
1. Select active column
2. Select entire column
3. Select first column to last column
4. The BubbleSort() procedure sorts a column of integer values from lowest to highest value
5. Array to Columns
6. Assign the value to the ColumnWidth property of the ActiveCell using:
7. Assign the column width of one cell to another cell on the active sheet, using:
8. Adjusting Column Widths
9. The Clear method
10. ClearContents method deletes the contents of the range but leaves the formatting intact.
11. ClearFormats method deletes the formatting in the range but not the cell contents.
12. The NumberFormat property represents the number format (expressed as a text string) of the Range object: statement changes the number format of column A to percent with two decimal places
13. Is in last column
14. Change column width
15. Make a range autofit
16. Returning the Last Used Cell in a Column or Row with Worksheet
ww___w___._j___a___v___a___2___s___.___co__m__ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.