Convert Number into a column heading
Hi all,
I request the help of the excel Gods. I've created a worksheet that does what i want to do but i'm not sure how to create a custom function using VBA to do the same thing. Any help pointers would be greatly appericated.
What i want to achieve is a function that when you pass a number it converts that number into a column heading and returns a string. eg. 5 = E, 66 = BN
Thanks for any help.
Re: Convert Number into a column heading
VB Code:
Debug.Print Split(Cells(, 66).Address, "$")(1)
Pieter
Re: Convert Number into a column heading
How do i use that line of code i'm confused.
Re: Convert Number into a column heading
You could use it in the following way:
VB Code:
Dim Number As Integer
Number = InputBox("Enter Number:")
MsgBox "The column name = " & Split(Cells(, Number).Address, "$")(1)
If your Number = 52 then
Cells(,Number).Address would return $AZ$1
The Split function splits $AZ$1 into two parts 1: 'AZ' 2: '1'
Split(,)(1) means you get the first part of the split function: the string 'AZ'.
Hope it helps.
Pieter