In this article we will learn about some of the frequently asked Visual Basic programming questions in technical like “excel vba column letter” Code Answer’s. When creating scripts and web applications, error handling is an important part. If your code lacks error checking code, your program may look very unprofessional and you may be open to security risks. Error handling in VBA is simple. An error message with filename, line number and a message describing the error is sent to the browser. This tutorial contains some of the most common error checking methods in Visual Basic. Below are some solution about “excel vba column letter” Code Answer’s.
excel vba function to convert column number to letter
xxxxxxxxxx
1
Function ColName(n)
2
ColName = Split(Cells(, n).Address, "$")(1)
3
End Function
excel vba column letter
xxxxxxxxxx
1
Function ColumnLetter(pColIndex As Long) As String
2
ColumnLetter = Replace(Cells(1, pColIndex).Address(True, False), "$1", "")
3
End Function
excel vba column letter to number
xxxxxxxxxx
1
Sub Test()
2
Debug.Print "result: " & getColIndex("DD") ' --> result: 108
3
End Sub
4
5
Function getColIndex(sColRef As String) As Long
6
Dim i As Long, sum As Long, iRefLen As Long
7
sum = 0: iRefLen = Len(sColRef)
8
For i = iRefLen To 1 Step -1
9
sum = sum + Base26(Mid(sColRef, i)) * 26 ^ (iRefLen - i)
10
Next
11
getColIndex = sum
12
End Function
13
14
Private Function Base26(sLetter As String) As Long
15
Base26 = Asc(UCase(sLetter)) - 64 'fixed
16
End Function