+ Reply to Thread
Results 1 to 7 of 7

Alternative to INDIRECT (and OFFSET)

  1. #1
    Registered User
    Join Date
    07-12-2016
    Location
    Denmark
    MS-Off Ver
    2016
    Posts
    4

    Alternative to INDIRECT (and OFFSET)

    Hi,

    I'm looking for an (non-volatile) alternative to the INDIRECT (and OFFSET function). I'm working with a price basis converter for a cash flow model, which converts a cash flow (starting in 2010) from e.g. N to R2017 taking corresponding year, a ccy cross vector (eg. EURUSD) and an inflation vector as input variables.

    In the original formula the OFFSET and INDIRECT function is used to select the right [width]" of the inflation vector and ccy cross vector.

    ....OFFSET(INDIRECT("y_"&$H27);0;1;1;[width])...

    Where the ["width"] is dynamic (eg. given by (2017-2010+1) and defined as (MAX(IF($G27="N";K$3;MID($G27;2;4)*1);IF($G28="N";K$3;MID($G28;2;4)*1))-MIN(IF($G27="N";K$3;MID($G27;2;4)*1);IF($G28="N";K$3;MID($G28;2;4)*1))))+1)

    Where "y_"&$H27 is a named range of the inflation vector and $G27 $G28 are input cells

    So far i'm trying to replace this by the INDEX function. Since the INDEX function doesn't have a [width] input, the reference range has to be changed dynamically. This could be done by using the ADDRESS function to define a range of the inflation vector, but hence it cannot be read by the INDEX formular without using INDIRECT..:

    ...INDEX(INDIRECT(INDEX(ADDRESS(MATCH("y_"&$H39;$H$1:$H$23;0);COLUMN(K$33))&":"&ADDRESS(MATCH("y_"&$H39;$H$1:$H$23;0);COLUMN(K$33)+(MID($G$33;2;4)-K$3-1));;));;)

    So does anyone know an alternative to the INDIRECT function, so that I can define a dynamic range as reference in the INDEX formula.??

    Such as..:

    ...INDEX(INDEX(ADDRESS(MATCH("y_"&$H39;$H$1:$H$23;0);COLUMN(K$33))&":"&ADDRESS(MATCH("y_"&$H39;$H$1:$H$23;0);COLUMN(K$33)+(MID($G$33;2;4)-K$3-1);;));;)...

    The function has to be dynamic to respond to user-changes of the input variable - hence hardcoded values will not work...

    Thank you!

  2. #2
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: Alternative to INDIRECT (and OFFSET)

    I dont usually say VBA is easier than using excel native functionality, but for this it likely is.
    I would have an event fire off so when any of the user manipulated variables change, it rips through and hard codes all the formulas appropriately.

    This means you have a potential bit of lag ONCE when the inputs change but then the formulas are quick as you dont have a ton of volatile formulas.
    Please ensure you mark your thread as Solved once it is. Click here to see how.
    If a post helps, please don't forget to add to our reputation by clicking the star icon in the bottom left-hand corner of a post.

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

    Re: Alternative to INDIRECT (and OFFSET)

    It will be difficult to work this without seeing the actual sheet's layout,
    Can you attach a copy of the book?

    Here's a general concept though to use the Width variable with Index

    =A1:INDEX(1:1,[width])

    If width = say 20, then that results in a range like
    A1:T1

    If the beginning cell is not in column A (say it's E), you'd have to do this
    =E1:INDEX(1:1,[width]+COLUMN(E1)-1)
    or
    =E1:INDEX(E1:IV1,[width])


    And you're correct, you cannot do this without indirect.
    "y_"&$H27
    Where H27 is say "Apple" and it completes a named range like y_Apple
    Last edited by Jonmo1; 08-10-2016 at 10:38 AM.

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

    Re: Alternative to INDIRECT (and OFFSET)

    You can also do this for the Named Range bit instead of the Indirect.
    Though it can get cumbersome..

    =CHOOSE(MATCH(H27,$A$1:$A$4,0),y_Apple, y_Pear, y_Banana, y_Peach)

    Where H27 = say Pear, and A1:A4 = Apple Pear Banana Peach

  5. #5
    Registered User
    Join Date
    07-12-2016
    Location
    Denmark
    MS-Off Ver
    2016
    Posts
    4

    Re: Alternative to INDIRECT (and OFFSET)

    Thank you for the replies!

    @mikeTron
    You're probably right!..

    @Jonmo1
    I guess it's still not possible to combine the width feature (=E1:INDEX(E1:IV1,[width]))) of the index function with a dynamic part to define a the range .."=E1:INDEX(E1:IV1..".., like =ADRESS(ROW(xx);Collumn(xx)):INDEX(ADRESS(ROW(xx);Collumn(xx))+x;[width]))...

    I will attach a sample of the workbook in a minute

  6. #6
    Registered User
    Join Date
    07-12-2016
    Location
    Denmark
    MS-Off Ver
    2016
    Posts
    4

    Re: Alternative to INDIRECT (and OFFSET)

    Hi

    Attached is a short version of the original model.

    Thank you.
    Attached Files Attached Files

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

    Re: Alternative to INDIRECT (and OFFSET)

    Forget using Address...
    Use Index instead.

    =INDEX($A:$IV,row#1,col#1):INDEX($A:$IV,row#2,[width]+col#1-1)

    i.e.
    =INDEX($A:$IV,5,10):INDEX($A:$IV,7,20+10-1)
    That will result in a range
    J5:AC7 - A range 20 columns wide, beginning in J

    You need only ensure that A:IV is sufficiently wide enough to accomodate your column variables.
    So instead of A:IV, maybe use A:XFD
    Last edited by Jonmo1; 08-11-2016 at 08:51 AM.

+ 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] INDIRECT or alternative?
    By ungers in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-01-2014, 08:33 AM
  2. [SOLVED] VB alternative to using INDIRECT.EXE?
    By xlyfe in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-27-2014, 02:35 PM
  3. [SOLVED] SpeedUp/Alternative to Offset.Value = Offset.Value
    By Jovica in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-13-2013, 01:43 AM
  4. Indirect Alternative
    By par0016 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 02-07-2013, 02:45 AM
  5. Alternative for INDIRECT
    By Hein in forum Excel General
    Replies: 11
    Last Post: 01-27-2009, 05:42 AM
  6. Alternative To INDIRECT?
    By SamuelT in forum Excel General
    Replies: 3
    Last Post: 11-20-2008, 03:53 PM
  7. Alternative to Indirect
    By [email protected] in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-20-2006, 07: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