+ Reply to Thread
Results 1 to 11 of 11

vlookup with random gaps in rows (hard to explain see attached sheet!)

  1. #1
    Registered User
    Join Date
    04-06-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    17

    vlookup with random gaps in rows (hard to explain see attached sheet!)

    Hi

    I have a sheet (attached) where data is put into columns J, K, L and M. This is in sets which can vary from one to six rows and it is random as to how many rows each set will have. I need to transfer the values over to columns A, B, C and D but the problem is that A, B, C and D are fixed at six rows each in order to accommodate the maximum number of rows each set can have (I cannot change this). How do I get the data from J, K, L & M into A, B, C & D? I have tried various vlookups but it cannot account for the random placing of the gaps in the sets.

    The sheet attached shows how it would look with the data transferred. Can anyone help with a suitable formula to do this please.
    Attached Files Attached Files

  2. #2
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: vlookup with random gaps in rows (hard to explain see attached sheet!)

    =IF(MAX($E$1:$E2)-LARGE($E$1:$E2,2)-CHOOSE(1+MOD(ROW()-1,6),6,1,2,3,4,5)>0,INDEX(J:J,LARGE($E$1:$E2,2)+MOD(ROW()-1,6)),"")
    with a helper column
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    04-06-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: vlookup with random gaps in rows (hard to explain see attached sheet!)

    It certainly seems to work but if I add any new data to columns J,K,L,M it resets all cells in A, B, C, D,E to #NAME?

  4. #4
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: vlookup with random gaps in rows (hard to explain see attached sheet!)

    What do you mean: new?
    Those tables should be in different sheets.

  5. #5
    Registered User
    Join Date
    04-06-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: vlookup with random gaps in rows (hard to explain see attached sheet!)

    For example if I add another set of data in your sheet, say cell J26 - M26 it resets A, B, C, D, E to #NAME? I need to be able to add data. In the attached I have added data in cells J26:M26 and it has reset.
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    11-27-2007
    Location
    New Jersey, USA
    MS-Off Ver
    2013
    Posts
    1,669

    Re: vlookup with random gaps in rows (hard to explain see attached sheet!)

    How about using VBA.
    See attached sample.
    Click on the button and it will move data as you want.
    When you add data it will work as well.
    Attached Files Attached Files

  7. #7
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: vlookup with random gaps in rows (hard to explain see attached sheet!)

    it works as intended
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    11-27-2007
    Location
    New Jersey, USA
    MS-Off Ver
    2013
    Posts
    1,669

    Re: vlookup with random gaps in rows (hard to explain see attached sheet!)

    Here's the macro.

    HTML Code: 

  9. #9
    Registered User
    Join Date
    04-06-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: vlookup with random gaps in rows (hard to explain see attached sheet!)

    The VBA routine is just the job so I will go with that. Thanks to all for your input it is much appreciated.

  10. #10
    Forum Expert
    Join Date
    11-27-2007
    Location
    New Jersey, USA
    MS-Off Ver
    2013
    Posts
    1,669

    Re: vlookup with random gaps in rows (hard to explain see attached sheet!)

    If you are satisfied with the solution, please mark this thread "Solved".
    Appreciate your feedback and reputation if you so choose.

  11. #11
    Registered User
    Join Date
    04-06-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: vlookup with random gaps in rows (hard to explain see attached sheet!)

    Quote Originally Posted by tim201110 View Post
    it works as intended
    I was surprised this did not work for me but I have found out what the problem is! I am using Excel 2007 and the formula you used unfortunately does not work with my version. When I open your sheet it displays the values correctly but as soon as I do anything to make the formula recalculate it reports the error code and puts a prefix in front of the formula: =_xlfn.AGGREGATE(15,6,ROW($J$2:$J$10000)/ISBLANK($J$2:$J$10000),COUNTA($E$1:E1)).

+ 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. Replies: 5
    Last Post: 01-19-2017, 05:46 PM
  2. Replies: 7
    Last Post: 12-08-2014, 09:05 PM
  3. [SOLVED] Hard to explain, please help
    By FooFighter616 in forum Excel General
    Replies: 4
    Last Post: 06-13-2012, 02:20 PM
  4. Hard to explain question
    By odditie in forum Excel General
    Replies: 4
    Last Post: 02-16-2007, 05:09 PM
  5. [SOLVED] Help with spread sheet (Hard to explain)
    By facebuddies in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-08-2006, 11:04 AM
  6. Please help!!! This is hard to explain!
    By Robert Sadler in forum Excel General
    Replies: 4
    Last Post: 02-02-2005, 12:28 AM
  7. Please help!!! This is hard to explain!
    By Robert Sadler in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-01-2005, 05:48 PM

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