+ Reply to Thread
Results 1 to 2 of 2

Populating a cell with a formula that references a previous sheet in that workbook

  1. #1
    Registered User
    Join Date
    06-09-2015
    Location
    Arkansas, USA
    MS-Off Ver
    2013
    Posts
    4

    Populating a cell with a formula that references a previous sheet in that workbook

    I am using some VBA in a source workbook to create a new sheet in a Output workbook and copy/paste various information into that new sheet.
    Each time that my VBA is run, it will create another new sheet in that Output workbook.

    Here is the problem:
    A couple of the columns in my newly created sheet need to run vlookups and such on data in the previous sheet in the Output workbook.

    So, for example, if my VBA has been run a couple times before, and there now exist Sheet1, Sheet2, and Sheet3 in the Output workbook:
    I run the VBA again, and a new sheet, using the default name Sheet4, is created. I want to populate a formula into a column in Sheet4 that will vlookup info from Sheet3. When the VBA is run again later, creating Sheet5, there will be a column in there that executes a vlookup against Sheet4...and so on.

    Unfortunately, I cannot figure out any way to either have a formula directly reference the immediately preceding worksheet in its workbook (without knowing the name of the sheet), or to have VBA obtain the name of the immediately preceding sheet and use that to populate a vlookup formula in my new sheet.

    Any ideas? More info needed?

    Any help would be appreciated.

  2. #2
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: Populating a cell with a formula that references a previous sheet in that workbook

    I use a popular UDF called SHEETOFFSET:

    Please Login or Register  to view this content.
    =SHEETOFFSET(-1,B3) will return the value in B3 on the previous sheet, regardless of that sheet's name. Similarly, =SHEETOFFSET(2,B5) will return B5 from two sheets forward.

+ 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 for working out and populating a table using the previous month totals
    By amasson in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-24-2014, 11:12 AM
  2. Replies: 3
    Last Post: 10-07-2013, 03:34 PM
  3. Formula for populating data into another sheet/workbook
    By Woodsnv1 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-16-2013, 08:20 PM
  4. Macro that references a cell on previous sheet
    By timrecords in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-10-2013, 10:08 AM
  5. Replies: 3
    Last Post: 09-29-2011, 02:21 PM
  6. Replies: 3
    Last Post: 01-09-2010, 08:42 AM
  7. [SOLVED] replace formula references with previous sheet names
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-22-2006, 09:35 AM

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