+ Reply to Thread
Results 1 to 4 of 4

Indirectly referencing a defined named range in a formula

  1. #1
    Forum Contributor
    Join Date
    03-26-2014
    Location
    Kentucky
    MS-Off Ver
    Excel 2013
    Posts
    128

    Indirectly referencing a defined named range in a formula

    I am trying to reference a defined named range in a formula indirectly, but with no luck. I have a worksheet function that gives me the defined name by returning the name of the sheet tab (as shown below). An example to clarify: the name of the sheet tab is "Blue", which "Blue" is also a named range of cells from another sheet.

    Function TabName()
    TabName = ActiveSheet.Name
    End Function


    Here is an example of the formula I am trying to get this to work on:
    =INDEX(TabName(),MATCH(TRUE,ISNUMBER(SEARCH(TabName(),A1)),0))

    Essentially it would be the same as the formula below, which does work:
    =INDEX(Blue,MATCH(TRUE,ISNUMBER(SEARCH(Blue,O13)),0))

    Basically, when I use the TabName() function, similarly if I reference a cell with the defined name, the formula does not identify it as the defined named range. Any help would be greatly appreciated!

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Indirectly referencing a defined named range in a formula

    I see multiple layers of problems in this approach. To give better advice it would be helpful to explain your overall problem--why do you have named ranges defined for each sheet, and why are you interested in ActiveSheet? The reason for these questions will be clear from my points below:

    1) The Function will not automatically be reevaluated every time you change the active sheet. Functions are automatically evaluated if a range that is one its arguments changes. You can mitigate this somewhat by making the function Volatile, which will cause it to be reevaluated whenever any cell in the workbook changes, but I think it will still not reevaluate just by changing the active sheet.

    2) Even if 1 were not true, I'm not sure how this function is useful, because any time you look at the sheet containing the formula, that sheet becomes the active sheet. So I don't know how you would ever expect a result that references a different sheet.

    3) Even if 1 and 2 were not true, the function returns a String; it does not return a Range. So the result is not essentially the same as the formula you showed; it is the same as this:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    The correct VBA code for this would be

    Please Login or Register  to view this content.
    This assumes that you have defined a range name that matches each sheet name.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Contributor
    Join Date
    03-26-2014
    Location
    Kentucky
    MS-Off Ver
    Excel 2013
    Posts
    128

    Re: Indirectly referencing a defined named range in a formula

    Thank you 6StringJazzer!! Using your VBA code, the formula worked. I apologize for my lack of description with this scenario, but I greatly appreciate you for getting back to me so quickly!

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Indirectly referencing a defined named range in a formula

    If your question has been answered please mark your thread as "Solved" so that members will know by looking at the thread title that your problem is solved. Go to the menu immediately above your first post to the thread and click on Thread Tools. From the dropdown menu select "Mark this thread as solved..."

    If a member helped you solve your problem, consider adding to their reputation by clicking on the star icon addreputationicon.jpg below their name.

+ 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] Help with .formula referencing named range and ribbon entry
    By icyrius in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-11-2016, 03:41 PM
  2. Replies: 9
    Last Post: 11-19-2014, 04:15 PM
  3. Indirectly referencing the name of a named range
    By dustinseely in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-02-2012, 08:54 PM
  4. [SOLVED] Indirectly referencing a worksheet within a formula
    By hackwill in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-26-2012, 07:22 PM
  5. Refer indirectly to named range
    By chartguy in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-16-2009, 12:50 PM
  6. Referencing cell in Named Range in Function VS Formula
    By Nyq in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-13-2006, 03:56 PM
  7. [SOLVED] Indirectly referencing a formula on a different sheet
    By Andy in forum Excel General
    Replies: 14
    Last Post: 09-05-2005, 11:05 AM

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