+ Reply to Thread
Results 1 to 22 of 22

VLOOKUP formula that will relatively adjust rows by a block of 8 rows with absolute column

Hybrid View

  1. #1
    Registered User
    Join Date
    03-23-2012
    Location
    Malibu, California
    MS-Off Ver
    Excel 2007
    Posts
    39

    VLOOKUP formula that will relatively adjust rows by a block of 8 rows with absolute column

    I have numerous blocks of data in 2 columns and 8 rows, and within each block I need to do repeated V-lookups to arrange the data in a different order on 4 separate spreadsheets (other workbooks). The columns are absolute (A & B), but I am constantly adding new rows in blocks of 8. Using a relative reference on the rows only adjusts them by one row. Is there a way to get them to adjust by 8 rows?

    Each cell in the first column contains 3 letters of text that are unique within each block, but repeat again in each new block, although the order varies based on the corresponding numeric value in column B (in descending order).

    I don't know if there is a formula for that, or a way to assign range names automatically, or set up tables or arrays, or some kind of macro to do this? The new data comes in by date, so I would consider using a third column with dates to trigger a new range name. (There is daily data on one sheet, weekly data on one sheet, monthly data on one sheet, etc. so even the dates will be tricky to use as range names since some data will overlap.)

    I would like to automate this process as much as possible. Suggestions would be greatly appreciated!

    Stevie the Kid

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: VLOOKUP formula that will relatively adjust rows by a block of 8 rows with absolute co

    You get better help if you post an Excel-example of your workbook, without confidential information.

    Make sure the workbook demonstrates your desired results if possible, or just highlight the cells you're trying to fix.

    Use BEFORE/AFTER sheets if that helps make it clearer.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  3. #3
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: VLOOKUP formula that will relatively adjust rows by a block of 8 rows with absolute co

    Can you post a sample workbook using non-confidential data, but in exactly the same layout as your real sheet.

    You can make the row relative in blocks using a combination of index, row and floor / ceiling functions. (the sample layout will make it easier to factor in any adjustments needed).

  4. #4
    Registered User
    Join Date
    03-23-2012
    Location
    Malibu, California
    MS-Off Ver
    Excel 2007
    Posts
    39

    Re: VLOOKUP formula that will relatively adjust rows by a block of 8 rows with absolute co

    There should be an Excel attachment here showing sample source data and the desired result. Note that the same text appears in column A within each block of 8 rows, and the order varies in relation to the corresponding values in column B, which are listed in descending order within each 8 row block.

    The desired result was achieved using a V-lookup formula, however currently the source data range needs to be entered manually each time as the formula must shift to each new block of 8 rows for each new row of sorted data, for each new date, as new data is added. (This sorted data then needs to go to 4 other spreadsheets.)

    I would like to somehow automate this process so that each new range doesn't have to be entered manually but will automatically adjust for each new block of 8 rows. I am open to suggestions on how to do this.

    Jason.b75, I am not familiar with using index, row and floor / ceiling functions, but I am intrigued and interested to hear how this might work in this situation.

    If I can provide further clarification, please let me know. Thanks so much for any help provided.
    Attached Files Attached Files

  5. #5
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: VLOOKUP formula that will relatively adjust rows by a block of 8 rows with absolute co

    Enter the formula in A22, then copy right and down

    =VLOOKUP(A$21,INDEX($A:$A,(ROWS(A$22:A22)-1)*8+2):INDEX($B:$B,ROWS(A$22:A22)*8+1),2,0)

  6. #6
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: VLOOKUP formula that will relatively adjust rows by a block of 8 rows with absolute co

    I don't think the solution of jason.b75 will work.

    (ROWS(A$22:A22)-1)*8+2)
    will give the result 170.

    although it is a nice try

    Above formula works perfect, see my reply on #10.


    I advice you to use the formula in the added workbook.

    Please read for this sentence: You can also use the formula in the added workbook.

    Do you get questions on this, just ask.
    Attached Files Attached Files
    Last edited by oeldere; 07-07-2012 at 05:29 AM. Reason: [COLOR="#FF0000"][/COLOR][U][/U][B]Above formula works perfect, see my reply on #10.[/B]

  7. #7
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: VLOOKUP formula that will relatively adjust rows by a block of 8 rows with absolute co

    why do you think it =170?
    (ROWS(A$22:A22)-1)*8+2) =2
    (ROWS(A$22:A23)-1)*8+2)=10
    the formula posted by jason.b75 works just fine mind you id probably use =(ROWS($A$1:A1)-1)*8+2 (just so i can see it starts at 1)
    Last edited by martindwilson; 07-07-2012 at 04:34 AM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  8. #8
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: VLOOKUP formula that will relatively adjust rows by a block of 8 rows with absolute co

    I try again in my sheet, I will come back with the result.

    I tried again.

    I still get the result 170.

    This is also my expected value, because

    row(a$22:a22) = 22

    row(22-1)=21

    21 * 8 = 168

    168 + 2 = 170

    What's going wrong in my explaination?

    Please reply.

    Notice that i don't want to affend anybody!!
    Last edited by oeldere; 07-07-2012 at 04:46 AM.

  9. #9
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: VLOOKUP formula that will relatively adjust rows by a block of 8 rows with absolute co

    Quote Originally Posted by martindwilson View Post
    id probably use =(ROWS($A$1:A1)-1)*8+2 (just so i can see it starts at 1)
    Personal preference is to start with the cell holding the first formula, using a different range will cause problems if rows are inserted / deleted.

    edit:

    A simple test in a blank worksheet

    In A22 enter =ROWS(A$22:A22) and in B22 enter =ROWS(A$1:A1)

    Copy both down for 10 rows. Delete row 2 (entire row) and insert a new row at row 5.

    Now compare the 2 columns, in column B, 1 is duplicated, 5 is missing, in column A nothing has changed.
    Last edited by jason.b75; 07-07-2012 at 06:28 AM.

  10. #10
    Registered User
    Join Date
    03-23-2012
    Location
    Malibu, California
    MS-Off Ver
    Excel 2007
    Posts
    39

    Re: VLOOKUP formula that will relatively adjust rows by a block of 8 rows with absolute co

    Quote Originally Posted by jason.b75 View Post
    Personal preference is to start with the cell holding the first formula, using a different range will cause problems if rows are inserted / deleted.

    edit:

    A simple test in a blank worksheet

    In A22 enter =ROWS(A$22:A22) and in B22 enter =ROWS(A$1:A1)

    Copy both down for 10 rows. Delete row 2 (entire row) and insert a new row at row 5.

    Now compare the 2 columns, in column B, 1 is duplicated, 5 is missing, in column A nothing has changed.
    Wow, this was very enlightening and you gave a great example! So good to know your formula will work even if rows are deleted or inserted! Thanks so much for sharing this, I learned something. (Now can you show me the syntax for referring to a different sheet for the source data versus the desired results? Would the sheet name go after INDEX, as in INDEX,Sheet 1!, etc.? And is the name of the workbook also required?)

  11. #11
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: VLOOKUP formula that will relatively adjust rows by a block of 8 rows with absolute co

    rows() not row()

  12. #12
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: VLOOKUP formula that will relatively adjust rows by a block of 8 rows with absolute co

    @Martindwilson

    Thanks for the reply.

    I didn't know this formula (rows).

    I added the formula of jason.b75 also in the workbook (see the orange cells).

    As you already replied it works perfect

    I will change the reply in my other reply, so there can be no misunderstanding.

    Thanks Martin, learned something today.
    Attached Files Attached Files
    Last edited by oeldere; 07-07-2012 at 05:35 AM.

  13. #13
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: VLOOKUP formula that will relatively adjust rows by a block of 8 rows with absolute co

    Pl see the attached file.
    As per the desired results shown in your sheet, Array formula is in Cell D5.It can be dragged.
    Any clarification welcome.
    Attached Files Attached Files

  14. #14
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: VLOOKUP formula that will relatively adjust rows by a block of 8 rows with absolute co

    Quote Originally Posted by kvsrinivasamurthy View Post
    Array formula is in Cell D5.It can be dragged.
    Any clarification welcome.
    The only downside to that would be the number of calculations required in the array, try that with a few hundred records and you'll have to wait an age for it to calculate.

  15. #15
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: VLOOKUP formula that will relatively adjust rows by a block of 8 rows with absolute co

    the moral is don't delete rows! but thanks for the info,mind you i never had a sheet where i'd delete a row.
    Last edited by martindwilson; 07-07-2012 at 08:14 AM.

  16. #16
    Registered User
    Join Date
    03-23-2012
    Location
    Malibu, California
    MS-Off Ver
    Excel 2007
    Posts
    39

    Re: VLOOKUP formula that will relatively adjust rows by a block of 8 rows with absolute co

    Thank you to everyone who replied; this is tremendous information and I plan to incorporate it as soon as possible, (without deleting any rows)! And to jason.b75, this worked perfectly in the example! However, I should have shown that I will need to refer to a different worksheet for the source data, and I am not familiar enough with the syntax or with what this formula is actually doing to adjust it to reference a separate sheet. (I apologize that my example should have shown that.)

    For instance if rows A21:H23 were on Sheet 2 in B2:I3, how would that syntax look to refer to the data on Sheet 1?

    If anyone could help me out with this that would be amazingly awesome!

  17. #17
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: VLOOKUP formula that will relatively adjust rows by a block of 8 rows with absolute co

    See the example.
    Attached Files Attached Files

  18. #18
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: VLOOKUP formula that will relatively adjust rows by a block of 8 rows with absolute co

    =VLOOKUP(A$21,INDEX('other sheet'!$A:$A,(ROWS(A$22:A22)-1)*8+2):INDEX('other sheet'!$B:$B,ROWS(A$22:A22)*8+1),2,0)
    Last edited by martindwilson; 07-07-2012 at 05:58 PM.

  19. #19
    Registered User
    Join Date
    03-23-2012
    Location
    Malibu, California
    MS-Off Ver
    Excel 2007
    Posts
    39

    Re: VLOOKUP formula that will relatively adjust rows by a block of 8 rows with absolute co

    Wow, yes, this works perfectly! A huge thanks to all who wrote in and special thanks to jason.b75, martindwilson and oeldere for your help and input! I not only got a formula that did exactly what I needed, but I also learned something new. This will save me a ton of time in the future. Many thanks and I hope to work with you all again.

    Stevie the Kid

  20. #20
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: VLOOKUP formula that will relatively adjust rows by a block of 8 rows with absolute co

    I'm interested in which solution you will use.

  21. #21
    Registered User
    Join Date
    03-23-2012
    Location
    Malibu, California
    MS-Off Ver
    Excel 2007
    Posts
    39

    Re: VLOOKUP formula that will relatively adjust rows by a block of 8 rows with absolute co

    Many thanks again to all who replied! A great discussion and everyone's input was invaluable. I learned a lot and was able to solve my problem, with several viable options to choose from.

    I ended up using jason.b75's formula because it seemed the most versatile with regard to easily handling hundreds of records, as well as being able to insert/delete rows if necessary. A majorly big thanks to you, jason.b75! This will save me many, many hours of work and I am thrilled with the results!

    A big thanks also to oeldere and martindwilson for also contributing great solutions! It was actually difficult to choose which option to use as all 3 would have worked fine. The examples from everyone were extremely helpful. I couldn't have asked for better or more creative solutions that show how to think outside the box.

    Thank you, thank you, thank you!!!
    Last edited by DPKologie; 09-01-2012 at 06:44 PM.

  22. #22
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: VLOOKUP formula that will relatively adjust rows by a block of 8 rows with absolute co

    Glad I could help.

    Thanks for the reply.

+ 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