Use this vba code. Function Col_Letter_To_Number(ColumnLetter As String) As Double Dim cNum As Double 'Get Column Number from Alphabet cNum = Range(ColumnLetter & "1").Column 'Return Column Number Col_Letter_To_Number = cNum End Function In Excel sheet, type ‘=Col_Letter_To_Number(...
III.Excel Formula to Get Column Letter from Number Get vba code & Excel formula to get Column letter from column number, in here. For example, If you pass ‘1’ to the function in this code, it will return as “A”. Similarly “B” for 2, “C” for 3 & so on. ...
a column number to its corresponding column letter in Excel with VBA code using 3 methods: converting a specific column number to its column letter, converting a user-input column number to its letter, and creating a UDF (User-Defined Function) to convert a column number to its letter.Method...
PublicFunctionColumnNumber(col_letterAsString)AsLongColumnNumber = Columns(col_letter).ColumnEndFunction Insert the code in your VBA editor as explainedhere, and your new function namedColumnNumberis ready for use. The function requires just one argument,col_letter, which is the column letter to ...
VBA Excel 常用 自定义函数 1. 将 互换 Excel 列号(数字/字母) Public Function excelColumn_numLetter_interchange(numOrLetter) As String Dim i, j, idx As Integer Dim letterArray letterArray = Array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',...
Column 1. 选择整列 Sub SelectEntireColumn() Selection.EntireColumn.Select End Sub 2. 将指定的列序号转换为列名 Function GetColumnRef(columnIndex As Integer) As String Dim firstLetter As String Dim secondLetter As String Dim remainder As Integer ...
Is there a code that would give the column letter(s) instead of the column number of the active cell. I use now the following code but are not satisfied with it and it is limited to the first 16 columns. Dim theLetter As String ...
Column 1. 选择整列 Sub SelectEntireColumn() Selection.EntireColumn.SelectEnd Sub 2. 将指定的列序号转换为列名 Function GetColumnRef(columnIndex As Integer) As String Dim firstLetter As String Dim secondLetter As String Dim remainder As Integer Select Case columnIndex / 26 Case Is <= 1 'Column...
2. Applying the User Defined Function to Change Column Letter to Number in Excel STEPS: Go to theDevelopertab and selectVisual Basicto open theVisual Basicwindow. SelectInsert >> Module. TheModulewindow opens. Enter the code below in theModulewindow: ...
CaseIs<=1'Column ref is between A and Z firstLetter=Chr(columnIndex+64) GetColumnRef=firstLetter CaseElse'Column ref has two letters remainder=columnIndex-26*(columnIndex\26) Ifremainder=0Then firstLetter=Chr(64+(columnIndex\26)-1)