+ Reply to Thread
Results 1 to 6 of 6

Variable to return name of worksheet in vlookup formula

  1. #1
    Forum Contributor
    Join Date
    11-02-2003
    Location
    Birmingham, UK
    MS-Off Ver
    Office 365
    Posts
    127

    Variable to return name of worksheet in vlookup formula

    I'm trying to write a formula which looks up the name of a worksheet to check if its in the index list.

    =SHEET returns the number of the worksheet, but is there a way I can get the assigned name into this formula please ?

    =vlookup("this worksheet name",index!A:A,1,false)

    A more elegant way to do it would be a formula that says If this worksheet name is in the index, then "ok", else "not indexed". I can only think of vlookup though.

    Thanks

    T'dub
    Terry

    "... I thought I was a power user of Excel until I came onto these boards..."

  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,942

    Re: Variable to return name of worksheet in vlookup formula

    do you have a list of sheet names somewhere?
    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
    11-02-2003
    Location
    Birmingham, UK
    MS-Off Ver
    Office 365
    Posts
    127

    Re: Variable to return name of worksheet in vlookup formula

    Yes, I have an index page with the list of names and hyperlinks to all the sheets..

    This formula is intended to provide a check as to whether the current sheet is included in this list or not.

    I have a team who use this particular workbook of over 50 sheets. Each time they add another sheet, I want them to add the name to the index as well to help with navigation. If they don't then this formula will inform them hopefully.

  4. #4
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Variable to return name of worksheet in vlookup formula

    So in column A of my worksheet I have a list of sheet names. If I put the name of the current sheet in that list and use this formula I get ok, if I remove the name I get not indexed.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    The A1 reference is just a cell on the sheet the formula is in, so that the formula returns the file name with the name of the sheet cell A1 is on. It doesn't matter what cell it is, nor does it matter if there is or isn't anything in that cell. If you reference a cell on another sheet, for instance Sheet2!A1 then it will return Sheet2 as the name to match. So just use A1 and it will always refer to the sheet the formula is on.

    Where I use A:A you probably want to reference your Index sheet and column A like you did in your first post, if that is where you sheet name list is kept.

    Good Luck.
    Last edited by skywriter; 10-04-2015 at 03:23 AM.
    Click the * Add Reputation button in the lower left hand corner of this post to say thanks.

    Don't forget to mark this thread SOLVED by going to the "Thread Tools" drop down list above your first post and choosing solved.

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,162

    Re: Variable to return name of worksheet in vlookup formula

    The attached macro-enabled workbook demonstrates a way of generating the sheet names automatically using a formula which was shared with me by someone here quite some time ago. Open it and look at the formula in Index | A1, which refers to a little macro called SheetNames. The formula can be dragged down as far as you like. Open the Name Manager on the Formula ribbon to add the simple macro.
    Attached Files Attached Files
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  6. #6
    Forum Contributor
    Join Date
    11-02-2003
    Location
    Birmingham, UK
    MS-Off Ver
    Office 365
    Posts
    127

    Re: Variable to return name of worksheet in vlookup formula

    Thank you Skywriter and Ali for your responses... consider this thread solved...

+ 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. [SOLVED] Formula to always return cell below what a vlookup would return
    By KCHEXCEL in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-28-2013, 12:57 AM
  2. [SOLVED] Vlookup to return multiple row from different worksheet
    By Tari in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-06-2013, 03:44 PM
  3. [SOLVED] VLOOKUP to return value from table dependent on 2 variable fields/values
    By ndtsteve in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-09-2012, 09:44 AM
  4. How to have variable worksheet name in VLookup?
    By SDBoca in forum Excel General
    Replies: 2
    Last Post: 11-16-2011, 12:57 PM
  5. Worksheet function Vlookup and VLOOKUP return different results
    By zandero in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-08-2010, 08:24 AM
  6. Vlookup with variable worksheet reference
    By trempnvt in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-23-2006, 01:50 PM
  7. VLOOKUP: Making a file and worksheet reference into a variable....
    By Mr Mike in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10:05 PM

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