+ Reply to Thread
Results 1 to 6 of 6

Help with INDIRECT() Function Using Autofill

  1. #1
    Registered User
    Join Date
    07-01-2015
    Location
    USA
    MS-Off Ver
    2013
    Posts
    7

    Question Help with INDIRECT() Function Using Autofill

    I am currently using the INDIRECT() function in multiple formulas to get around the design of a specific workbook. The workbook grabs data from a website and then sorts the data into a different spreadsheets within the workbook. Whenever new data is needed or the specific data to grab is changed, the workbook macro deletes the current spreadsheets holding the data and creates new spreadsheets containing the new data. The name of the spreadsheet stays the same, but the act of deleting the spreadsheet ruins the formulas unless INDIRECT() is used. Due to this, I have been using the INDIRECT() function so that the formulas in another spreadsheet that reference back to these deleted spreadsheets still work.
    Here is one of my formulas

    =IF((INDIRECT("'My Data'!B3")-INDIRECT("'My Data'!B2"))>0,INDIRECT("'My Data'!B3")-INDIRECT("'My Data'!B2"),0)

    However, due to the INDIRECT() function, I can't just autofill or drag down the formula, as it doesn't change any of the reference cells. I want it make the formula above go up in one cell each when I drag it down, so the formula above would be

    =IF((INDIRECT("'My Data'!B4")-INDIRECT("'My Data'!B3"))>0,INDIRECT("'My Data'!B4")-INDIRECT("'My Data'!B3"),0)

    I am need to use this formula to fill a lot of rows and columns, so I am looking for a fast way to be able to get excel to recognize the autofill formula I want.
    Any help would be much appreciated, thank you!

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: Help with INDIRECT() Function Using Autofill

    Try changing the row ref (3) a ROW() ref, something like...
    IF((INDIRECT("'My Data'!B"&row(A3))..........
    or
    IF((INDIRECT("'My Data'!B"&rows($A$1:A3))..........
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Help with INDIRECT() Function Using Autofill

    Try it like this...

    INDIRECT("'My Data'!"&CELL("address",B3))

    However, this is not "bulletproof". AFAIK, there is no bulletproof method of incrementing a cell ref within the INDIRECT function.

    On the sheet where this formula resides, if you were to insert a new row 3 then the cell reference to B3 would increment to B4 possibly leading to incorrect results.

    This is one of the biggest drawbacks to using INDIRECT.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  4. #4
    Registered User
    Join Date
    07-01-2015
    Location
    USA
    MS-Off Ver
    2013
    Posts
    7

    Re: Help with INDIRECT() Function Using Autofill

    Thank you very much, this seems to be working without a problem.

    I sincerely appreciate all the help received, it will save me hours of time.

  5. #5
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Help with INDIRECT() Function Using Autofill

    Glad you have solution.

    But as added value, you can pretty much cut the original formula in half

    =IF((INDIRECT("'My Data'!B3")-INDIRECT("'My Data'!B2"))>0,INDIRECT("'My Data'!B3")-INDIRECT("'My Data'!B2"),0)
    Could be
    =MAX(0,INDIRECT("'My Data'!B3")-INDIRECT("'My Data'!B2"))

    Now you only have to apply the solutions by Ford or Tony twice, instead of 4 times.

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: Help with INDIRECT() Function Using Autofill

    Thanks for the assist Jonmo, I honestly did not really even look at what the formula was doing, just at the question lol

+ 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] How to autofill across a row with an indirect function as part of a logical test?
    By unavailable in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-08-2015, 04:48 PM
  2. autofill indirect formula with moving average
    By jeff33 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-03-2015, 07:36 PM
  3. countif, indirect, autofill, help
    By idontwanttobeamember in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-17-2014, 09:16 PM
  4. Can't get Indirect range to autofill
    By kwarden01 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-07-2013, 11:11 AM
  5. Autofill INDIRECT with Worksheet cell reference
    By scottkelley80 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-04-2013, 08:49 PM
  6. Indirect? Autofill? Can't make anything work.
    By Grunty in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-15-2012, 10:40 PM
  7. [SOLVED] INDIRECT Function and Autofill
    By Neil Grantham in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-20-2005, 08:07 PM

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