+ Reply to Thread
Results 1 to 10 of 10

Excel 2007 : Offset - Positional Reference

  1. #1
    Registered User
    Join Date
    06-12-2012
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    6

    Offset - Positional Reference

    I'm trying to return the value of a cell when a match is found. I'm using the cells position to determine the return value. The position of the cell value is always the same RELATIVE to another criteria (ie TYPE II CO, REPASS, etc), which is why i'm using match, address, and offset. All of the code works so far except the last section (offset). The offset works for one position, but I want to position to vary based on the match.

    Here is my code so far:

    IF(AND(VLOOKUP(B20,A1:A16,1,TRUE),INDIRECT(ADDRESS(MATCH(B20,A1:A16,0)+1,1))="blank", INDIRECT(REPLACE(ADDRESS(MATCH(B20,A1:A16,0)+1,2),1,3,"B"))="TYPE II CO"),OFFSET(B4,-2,7,1,1),"nope")

    My problem/question:
    I want the reference cell in offset to be the position of a matched cell, however I get the following error when I try and input the position formula into offset "error..... too many arguments". I then tried to use the formula separately and feed offset the position of the cell, but offset is interpreting the actual position of the cell, not the referenced position (value) inside the cell.

    How do I get offset to accept the position value inside a cell and not use the actual position of the cell?

    Thanks, Let me know if the situation is not clear.Offset_Code_excelforums.xlsx
    Last edited by colorkid; 06-12-2012 at 12:07 PM.

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

    Re: Offset - Positional Reference

    I am not sure I understand the logic your after, but does this come close?

    =IFERROR(INDEX($I:$K,MATCH(B20,A:A,0)-1,MATCH(C19,$I$1:$K$1,0)),"nope")
    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.

  3. #3
    Registered User
    Join Date
    06-12-2012
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Offset - Positional Reference

    Thanks, NBVC. I really like your approach. I wasn't too familiar with index, but now I understand. However, with this code I would need to match the Item ID AND one of the categories. For example, I would need to find the ID (19587) and "TYPE II CO" (within the item). Once matched the cell location based off of "TYPE II CO" would be used to find the desired value.

    Essentially it would match the ID, then match "TYPE II CO" within that ID, then return the desired value by offsetting. The code you provided doesn't take into account that the position of times 2,3, 4, etc will move. This was my fault, my example was not clear enough as time 1 positions do no vary. The categories "TYPE II CO", "REPASS", etc. will vary in position within the ID, BUT the time will always be in the same position relative to the category. The time for "TYPE II CO" will always be 2 rows above it 8 columns over, etc.

    Thanks,

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

    Re: Offset - Positional Reference

    This should get you the TIME 1 based on TYPE II CO...

    Please Login or Register  to view this content.
    You need to just adjust the name (TYPE II CO) and the position for offset (i.e. the -2)

  5. #5
    Registered User
    Join Date
    06-12-2012
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Offset - Positional Reference

    That works great.

    I fully understand the code EXCEPT for the section: MATCH(B20,A1:A16,0)-1+MATCH("TYPE II CO",INDEX(B1:B16,MATCH(B20,A1:A16,0)):B16,0)-2

    I don't understand why you add the two row positions together. Why don't you just return the row position of the "TYPE II CO" and offset from that? why does the match(b20,a1:a16,0) need to be included?

    Hopefully I can repay the favor by solving some other people's problems on this forum. Other than that this problem is solved. Thanks again NBVC.

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

    Re: Offset - Positional Reference

    I try to avoid OFFSET function when I can since it is a Volatile function. Sometimes it leads to more complex formulas, but most of the time it is worth it to avoid constant re-calculations...

    So what I did was first find the Match for B20 in A1:A16, then added the MATCH of "TYPE II CO" in the subset of B1:B16 starting from row where B20 matched A1:A16 to end (B16)

    If you use the formula evaluator found in the Formula tab, you will be able to follow the steps.

  7. #7
    Registered User
    Join Date
    06-12-2012
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Offset - Positional Reference

    Ok. Cool. Keep on owning.

  8. #8
    Registered User
    Join Date
    06-12-2012
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Offset - Positional Reference

    For the spreadsheet attachedindex_match_sum_example.xlsxindex_match_sum_example.xlsx how could I modify the code would so it would give me a sum of the runq1 time (if that was the value to be searched for)? For example, I tell the code to sum all the runq1 and repass times, and it would (but it would keep them separate, repass:79min runq1:1045).

    Currently the code only finds the first value of the label searched for.

    The code is in the boxes below ALLOC, BATCH,... etc.
    Last edited by colorkid; 07-05-2012 at 12:24 PM.

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

    Re: Offset - Positional Reference

    I think the easiest way is to add a helper column, that will occupy each cell with relevant ItemID from column A.

    So in I2 enter formula:

    =LOOKUP(9.9999E+307,A$2:A2)

    copied down

    now in G16:

    =SUMIFS($F$2:$F$14,$I$2:$I$14,$F16,$B$2:$B$14,G$15)

    copied across and down, if you have more to check...

  10. #10
    Registered User
    Join Date
    06-12-2012
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Offset - Positional Reference

    Interesting. Done and done.

    Thanks NBVC

+ 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