Excel VBA to display column letter of a certain string

Posted on 2011-05-04
Last Modified: 2012-05-11
How can I  (with VBA not formula) return the column letter where a certain string is found in row 1?

So for example column letter where the string "Specialized" is found in row 1?

A string appears only once.

Question by:BrdgBldr
    LVL 24

    Accepted Solution

    You don't need VBA, but ...
    Sub x()
    Dim rFind As Range
    With Rows(1)
        Set rFind = .Find(What:="specialized", LookAt:=xlWhole, MatchCase:=False, SearchFormat:=False)
        If Not rFind Is Nothing Then
            MsgBox Split(rFind.Address, "$")(1)
        End If
    End With
    End Sub

    Open in new window


    Author Closing Comment

    :o) thank u!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    What is a Form List Box? (skip if you know this) The forms List Box is the alternative to the ActiveX list box. If you are using excel 2007, you first make sure you have a developer tab (click the Orb)->"Excel Options"->Popular->"Show Developer tab…
    INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
    Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
    This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now