+ 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
    01-06-2014
    Location
    Munich, Germany
    MS-Off Ver
    Excel 2013
    Posts
    1

    Copy a relative reference formula from one sheet to another.

    Hello!

    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
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,344

    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: 
    Attached Files Attached Files
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    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. 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. 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

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