+ Reply to Thread
Results 1 to 10 of 10

OFFSET func dynamic "reference"

  1. #1
    Registered User
    Join Date
    07-03-2007
    Posts
    8

    OFFSET func dynamic "reference"

    Hi, guys!
    I have the following issue to solve:
    I'd like to have a dynamic "reference" step for OFFSET function - unfortunately when I put vlookup there, the formula doesn't want to work.

    Here you are examples:
    1. =SUM(OFFSET(Actual!D125,0,0,1,$D$1),VLOOKUP($D12,Actual!$C$6:$O$597,2)) - this is working, as you can see the underlined references gives to the OFFSET the cell as reference

    but when i try to make it dynamic...

    2. =SUM(OFFSET(VLOOKUP($D12,Actual!$C$6:$D$597,2,0),0,0,1,$D$1),VLOOKUP($D12,Actual!$C$6:$O$597,2)) - here I replaced the single cell reference from previous example with the underlined one here and formula is not working.

    Please, help me on this thing...

  2. #2
    Forum Expert
    Join Date
    09-09-2005
    Location
    England
    MS-Off Ver
    2007
    Posts
    1,500
    what does VLOOKUP($D12,Actual!$C$6:$D$597,2,0) return

    the first arguement of the offset needs to be a cell. if the value of the lookup is say a cell address try

    indirect(VLOOKUP($D12,Actual!$C$6:$D$597,2,0))

    Regards

    Dav

  3. #3
    Registered User
    Join Date
    07-03-2007
    Posts
    8
    Yes, I've tried INDIRECT - it returns #ref...

    The problem is that the VLOOKUP returns the cell content and this mixed up the OFFSET function.. I need a way that VLOOKUP returns me the cell aws reference (for instance D125)... then it will works...

  4. #4
    Registered User
    Join Date
    07-03-2007
    Posts
    8
    Is there somebody with any ideas regarding my concern???

  5. #5
    Forum Expert
    Join Date
    09-09-2005
    Location
    England
    MS-Off Ver
    2007
    Posts
    1,500
    well you need to find which bit of the formual is not working, If you select a bit of the formula and press f9 it returns the value of that bit evaluated. If you do this for bits of the formual, you can see where the error originates

    =SUM(OFFSET(VLOOKUP($D12,Actual!$C$6:$D$597,2,0),0,0,1,$D$1),VLOOKUP($D12,Actual!$C$6:$O$597,2))

    I would first do the following steps
    1 ) what is the value of $d$1 , it should be a number >0
    2) what does VLOOKUP($D12,Actual!$C$6:$D$597,2,0) return, ? what do you want it to return
    3) does VLOOKUP($D12,Actual!$C$6:$O$597,2) return a value?

    Why not attach a small zipped version of the sheet so we can see what u want to do

    Regards

    Dav

  6. #6
    Registered User
    Join Date
    07-03-2007
    Posts
    8
    Hi, Dav!
    Thanks for your writing...!

    Right now I cannot attach a sheet (maybe later).

    The general idea is to make a YTD sum cell with two variables - month and cost center.
    1. $d$1 is number between 1 and 12 and it says to OFFSET [width] how many cells to include in the sum - here I use for monthly variable and it works

    2. VLOOKUP($D12,Actual!$C$6:$D$597,2,0) is returning me the cell value (some number), but I want to retrieve the cell reference (D125) and not the value - if I succeed to retrieve this, then OFFSET function will now which cell to use as starting point - actually here I look for the cost center number to match it with the row where I want to get YTD

    3. Yes, VLOOKUP($D12,Actual!$C$6:$D$597,2,0) returns a value as I wrote in point 2, but I need the cell and not the value...

  7. #7
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Does this work?

    Please Login or Register  to view this content.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  8. #8
    Registered User
    Join Date
    07-03-2007
    Posts
    8
    Wow, NBVC, you're real GURU, man! It works, thanks a lot!
    Thanks also to you, Dav!
    Still, NBVC, what exactly was my mistake? I can follow the formula, but if you can explain me more precisely?

  9. #9
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    The Index/Match function works like the Vlookup function and is even more flexible (you can make it work like a Vlookup/Hlookup combination too and you can lookup leftward also - vlookup can only go rightward)....

    Additionally, according to Excel help on the Index() function, the Index() function can return a reference as well as an actual value:

    Index: Returns a value or the reference to a value from within a table or range
    So depending on how you use the Index() function, you can get a value or a cell reference... In this case, within the OFFSET function, it returns a Reference because we placed it where a Reference is expected.

    Hope that helps!

  10. #10
    Registered User
    Join Date
    07-03-2007
    Posts
    8
    It really helps! Once again thanks a lot!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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