ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   convert column number to letter (https://www.excelbanter.com/excel-programming/343726-re-convert-column-number-letter.html)

Gord Dibben

convert column number to letter
 
Try this User Defined Function

Function GetColLet(ColNumber As Integer) As String
GetColLet = Left(Cells(1, ColNumber).Address(False, False), _
1 - (ColNumber 26))
End Function

usage is =GetColLet(25) will return Y

Can be called from a Sub

Sub getlet()
Dim numcol As Integer
numcol = InputBox("enter a number")
MsgBox "The column is " & GetColLet(numcol)
End Sub


Gord Dibben Excel MVP

On 24 Oct 2005 12:29:55 -0700, "lvcha.gouqizi"
wrote:

If I know a cell's column number is 25, how can I know what letter its
column represent? Just like that, the column 2 is actually column "B".
Thanks.



Crowbar via OfficeKB.com

convert column number to letter
 
Convert the sheet to letter:-

With Application
.ReferenceStyle = x1R1C1
.EnableSound = False
.RollZoom = False
End With
End Sub


Convert the sheet to numbers:-

With Application
.ReferenceStyle = xlR1C1
.StandardFont = "Arial"
.StandardFontSize = "10"
.EnableSound = False
.RollZoom = False
End With
End Sub


--
Message posted via http://www.officekb.com


All times are GMT +1. The time now is 12:45 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com