Results 1 to 4 of 4

Thread: Convert Number into a column heading

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2005
    Location
    Australia
    Posts
    46

    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.

  2. #2
    Lively Member
    Join Date
    Aug 2005
    Posts
    77

    Re: Convert Number into a column heading

    VB Code:
    1. Debug.Print Split(Cells(, 66).Address, "$")(1)

    Pieter

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2005
    Location
    Australia
    Posts
    46

    Re: Convert Number into a column heading

    How do i use that line of code i'm confused.

  4. #4
    Lively Member
    Join Date
    Aug 2005
    Posts
    77

    Re: Convert Number into a column heading

    You could use it in the following way:
    VB Code:
    1. Dim Number As Integer
    2. Number = InputBox("Enter Number:")
    3. 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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width