Micro How to VBA… Convert Numbers to their Alphanumeric Value

Open VBA, create a new module, and create a new function as follows.

Function Alphabetise(number As Long) As String

Dim a As Long
Dim b As Long

a = number
Alphabetise = ""

Do While number > 0
    a = Int((number - 1) / 26)
    b = (number - 1) Mod 26
    Alphabetise = Chr(b + 65) & Alphabetise
    number = a
Loop

End Function

This gives you access to a function in the Excel front-end called Alphabetise, that takes the number to convert as its argument. It converts from A to AZ.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s