Get column number instead of column number for searched value

  • Hi friends

    i tested this code


    Code
    Sub mymacro()
    Dim foundRng As Range
    Dim i As String
    Set foundRng = Range("A2:I5000").Find("college")
    If foundRng Is Nothing Then
    MsgBox "Value not found"
    Else
    MsgBox foundRng.Column
    End If
    End Sub

    it displays the column number 9. But i want to get column name i.e "I".

    please guide me

    Edited once, last by Carim: Code Tags ().

  • Hello,


    A tiny modification

    Code
    Sub mymacro2()
    Dim foundRng As Range
    Dim i As String
    Set foundRng = Range("A2:I5000").Find("college")
        If foundRng Is Nothing Then
            MsgBox "Value not found"
        Else
            MsgBox Split(Cells(1, foundRng.Column).Address, "$")(1)
        End If
    End Sub

    Hope this will help

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!