+ Reply to Thread
Results 1 to 2 of 2

Copy a relative reference formula from one sheet to another.

  1. #1
    Registered User
    Join Date
    Munich, Germany
    MS-Off Ver
    Excel 2013

    Copy a relative reference formula from one sheet to another.


    My simple problem is each new worksheet in certain cells needs to have the previous sheet identical cell value, plus an integer. I found a previous thread with a solution as follows. (and I quote)

    You can use a user-defined function. In a module, enter:
    Function Prevsheet(ref As Range)
    Set sh = Sheets(Range(Application.Caller.Address).Parent.Index - 1)
    Prevsheet = sh.Range(ref.Address)
    End Function

    In worksheet (except first):
    If Sheet1!A1 has 1, then in Sheet2!A1, enter: =Prevsheet(A1)+1 and you'll see 2.
    In Sheet3!A1, enter =Prevsheet(A1)+1 and you'll see 3 etc. End quote.

    While this works for the first sheet, when I copy this sheet I get a circular formula warning in relation to this and the value is zeroed.

    It obviously seems to work, but not quite. Any suggestion greatly appreciated. Craig

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365

    Re: Copy a relative reference formula from one sheet to another.

    It does work, but it seems a little temperamental so I'm not sure I would want to use it. I put some debug statements in to show what is happening. I found that, if I got the circular reference, going through each sheet (in order) and pressing F2 and Enter to re-commit the formula, it would work. Comment out the debug statements for live running. See the attached example.

    Please Login or Register  to view this content.

    And the output in the immediate window.

    HTML Code: 
    Application.Caller.Address: $A$1
    Range(Application.Caller.Address).Parent.Index: 2
    Range(Application.Caller.Address).Parent.Index -1: 1
    ActiveSheet.Name: Sheet2
    sh.Name: Sheet1
    Application.Caller.Address: $A$1
    Range(Application.Caller.Address).Parent.Index: 3
    Range(Application.Caller.Address).Parent.Index -1: 2
    ActiveSheet.Name: Sheet3
    sh.Name: Sheet2
    Application.Caller.Address: $A$1
    Range(Application.Caller.Address).Parent.Index: 4
    Range(Application.Caller.Address).Parent.Index -1: 3
    ActiveSheet.Name: Sheet4
    sh.Name: Sheet3
    Application.Caller.Address: $A$1
    Range(Application.Caller.Address).Parent.Index: 5
    Range(Application.Caller.Address).Parent.Index -1: 4
    ActiveSheet.Name: Sheet5
    sh.Name: Sheet4
    Application.Caller.Address: $A$1
    Range(Application.Caller.Address).Parent.Index: 6
    Range(Application.Caller.Address).Parent.Index -1: 5
    ActiveSheet.Name: Sheet6
    sh.Name: Sheet5
    Attached Files Attached Files
    Trevor Shuttleworth - Excel Aid

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke

+ 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: 5
    Last Post: 09-21-2012, 02:08 PM
  2. Copy and insert with relative reference to formulas
    By m-steele@shaw.ca in forum Excel General
    Replies: 6
    Last Post: 08-28-2012, 12:35 AM
  3. Relative Sheet Reference Syntax
    By adoepker in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-22-2011, 11:28 AM
  4. [SOLVED] Copy a relative reference formula from one sheet to another.
    By jannkatt in forum Excel General
    Replies: 3
    Last Post: 05-17-2006, 02:20 PM
  5. Copy selection based on relative reference
    By goofy11 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-19-2005, 01:05 PM


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