+ Reply to Thread
Results 1 to 9 of 9

Need Lookup Formula to Give Column Range

  1. #1
    Forum Contributor
    Join Date
    06-08-2008
    Location
    USA
    MS-Off Ver
    Mac Excel 2016
    Posts
    103

    Need Lookup Formula to Give Column Range

    I'm trying to write a formula that searches for the name of the column on one sheet, finds that column on another, then results in the column letter. So, ideally, if the first three columns in the first tab were "Team," "Name," and "Total," respectively, I just want a formula to search for "Name" and give me back "B."

    I want to do this in case anybody ever moves the "Name" column, for example, from column B to column C -- so then it would search for "Name" again and change the range in the formula to "C" because that's where that data lives now.

    Currently, I'm using it for a COUNTIF() function that is a very simple: =countif(indirect("'"&$A2&"'!K:K"),$B2), where A2 is the sheet name. The latter half of $B2 is fine -- but I would love to have a more complicated formula take the place of the range "B:B" in case the "Name" column ever got moved.

    Thanks!
    Last edited by rylock; 07-26-2014 at 05:33 PM.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,933

    Re: Need Lookup Formula to Give Column Range

    Sounds like you coud use INDEX/MATCH (or just MATCH) for this, if you have a sample workbook, we can see what we can come up with
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Contributor
    Join Date
    06-08-2008
    Location
    USA
    MS-Off Ver
    Mac Excel 2016
    Posts
    103

    Re: Need Lookup Formula to Give Column Range

    I actually may have figured out a way to get another cell in the spreadsheet to say "K" by doing lookups -- but I can't quite seem to insert that into my existing COUNTIF formula.

  4. #4
    Forum Contributor
    Join Date
    06-08-2008
    Location
    USA
    MS-Off Ver
    Mac Excel 2016
    Posts
    103

    Re: Need Lookup Formula to Give Column Range

    Quote Originally Posted by FDibbins View Post
    Sounds like you coud use INDEX/MATCH (or just MATCH) for this, if you have a sample workbook, we can see what we can come up with
    Thanks! That's what I ended up doing. Went with this (potentially overcomplicated) formula, but it works to give me back "K":

    Please Login or Register  to view this content.
    Now, as I said above -- I'd just need to figure out how to insert that into the COUNTIF statement above in place of the "K:K"

  5. #5
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: Need Lookup Formula to Give Column Range

    May be this.....

    Please Login or Register  to view this content.
    The formula will search for Name column in row1 and give you the count for first name from the name column. When the formula is dragged down, it will count the next name in the name column.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  6. #6
    Forum Contributor
    Join Date
    06-08-2008
    Location
    USA
    MS-Off Ver
    Mac Excel 2016
    Posts
    103

    Re: Need Lookup Formula to Give Column Range

    Sorry, sometimes I try to get away without posting sample files when I think it's possible to get an answer by just explaining -- but it's almost never that easy. I had to change things around a little bit, since it's just a sample; it's the same basic ideas as above, but the column range is now A:A instead of K:K and instead of looking up "Name," I'm looking up "District":

    ColumnRangeSample2.xlsx
    Last edited by rylock; 07-26-2014 at 06:26 PM. Reason: Fixed attachment

  7. #7
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: Need Lookup Formula to Give Column Range

    May be this.....

    On Summary Sheet
    In C2
    Please Login or Register  to view this content.
    and copy down.
    Does this help?

  8. #8
    Forum Contributor
    Join Date
    06-08-2008
    Location
    USA
    MS-Off Ver
    Mac Excel 2016
    Posts
    103

    Re: Need Lookup Formula to Give Column Range

    That seems to do it! Thanks again!

  9. #9
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: Need Lookup Formula to Give Column Range

    You're welcome.
    You may also click on * (star) to Add Reputation if the solution provided helped you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 04-16-2014, 05:13 PM
  2. Exclusive Lookup to match Rowwise data and give the Column Heading..
    By e4excel in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 06-26-2010, 04:00 AM
  3. Replies: 1
    Last Post: 10-20-2006, 05:24 AM
  4. Replies: 5
    Last Post: 07-17-2005, 02:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1