Consulting

Results 1 to 7 of 7

Thread: Controlling Defined Name Scope

  1. #1

    Controlling Defined Name Scope

    When I define a name for cell A1, then Excel creates the ?Refers to? formula by prefixing the active sheet?s name to the A1 so it looks like: =Sheet1!$A$1.

    My question is, can I define a name so that it will refer to the cell A1 on whatever the active sheet happens to be at the moment? In other words, can the definition be made so that the ?Refers to? listing omits the sheet name prefix?

    A variation of this question is: can I define a name so that it would apply to only certain sheets, and not to others?

    This would be handy if I want to write a date/time stamp in the same location of each sheet that I update.

  2. #2
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    Cyberdude

    I just created a named range that referred to =!A1.

    I then put =NamedRange in cells on all the sheets in the workbook and enter values in A1.

    The cells with =NamedRange did return the value in A1 of the sheet they were on but they didn't seem to update automatically.

    ie I had to goto the cells, F2 and enter.

    Don't know if that's something to do with my current setup or with what I tried.

  3. #3
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Try calling your cell Print_Area! That seems to work
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  4. #4
    Surely you jest . . . "Print_Area!"???

    OK, I defined cell A1 to have the name "TestCell", then I wrote (giggle) =Print_Area!A1 in the Refers to area.
    At first it seemed to be OK. Then when I referred to it in a formula, I got an "Update Values: Print Area" window, which I cancelled. Then I looked at the "TestCell" definition again, and it had been changed to =Print_Area!IV65534

    I suspect that is not a workablesolution, but thanks.

  5. #5
    Can't you write a Worksheet_Activate sub that will redefine your range?

  6. #6
    MS Excel MVP VBAX Mentor Andy Pope's Avatar
    Joined
    May 2004
    Location
    Essex, England
    Posts
    344
    Location
    Try adding a name with the Refers to

    =OFFSET(!$A$1,,,,)

    Created by Bob Umlas and David Hager
    Cheers
    Andy

  7. #7
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    Andy

    Nice one, and it updates automatically.

Posting Permissions

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