+ Reply to Thread
Results 1 to 5 of 5

Formula/VBA to Vlookup multiple values both horizontally and vertically

  1. #1
    Registered User
    Join Date
    09-17-2014
    Location
    Cambridge, England
    MS-Off Ver
    2016
    Posts
    58

    Formula/VBA to Vlookup multiple values both horizontally and vertically

    Hello,

    I have a problem output from one of our databases...

    Essentially it is built so that multiple outputs from single clients can span multiple Rows with each row giving different details about that single client.

    I want to be able to transform the data either through a Formula (would be best) or VBA - but having a new tab show the unique client ID just once on its own row, but then the various data that may appear for that client to be shown horizontally over a number of columns.

    Each client may appear just once in the initial extra, so will only have a matching value in one of the horizontal columns in the end result, or they may appear 200 times with 200 various peices of information that I would need to span over the 200 columns on the end results.

    I do have some VBA for this, but I am not sure how to alter it or come up with a formula variant.

    My current VBA code is as follows...
    Please Login or Register  to view this content.
    However, this will only output as many columns as appears for the person - I ideally want it to pull through the Row values based on a set list of headers, and fill in the matches it fails on with a 'N/A' value.

    I have attached a test spreadsheet to show what I am looking to get to, but just cannot see what I may need to change to get to it.

    Hopefully someone is able to help, and I would be most grateful if any is able to.
    Attached Files Attached Files

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,036

    Re: Formula/VBA to Vlookup multiple values both horizontally and vertically

    Using a formula, in B2,copied across and down:

    =IFERROR(INDEX(Extract!$C$2:$C$13,MATCH(1,INDEX(((Extract!$A$2:$A$13='Desired Result'!$A2)*(Extract!$B$2:$B$13='Desired Result'!B$1)),0),0)),"")

    If you want something other than a blank in the non-matching cells, put whatever text you need inside the red quotation marks.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: Formula/VBA to Vlookup multiple values both horizontally and vertically

    Hi,
    please try in A2 and down:
    =IFERROR(INDEX(Extract!$A$2:$A$13,AGGREGATE(15,6,(((ROW(Extract!$A$1:$A$12))/(MATCH(Extract!$A$2:$A$13,Extract!$A$2:$A$13,0)=(ROW(Extract!$A$1:$A$12))))),ROWS(Extract!$G$1:G1))),"")

    B1 and drag to the right:
    =INDEX(Extract!$B$1:$B$13,AGGREGATE(15,6,((ROW(Extract!$B$2:$B$13))/(MATCH(Extract!$B$2:$B$13,Extract!$B$2:$B$13,0)=ROW(Extract!$B$1:$B$12))),COLUMNS(Extract!$H$1:H1)))

    B2 and across for the numeric values:
    =IFNA(INDEX(Extract!$C$2:$C$13,MATCH('Desired Result'!$A2&'Desired Result'!B$1,Extract!$A$2:$A$13&Extract!$B$2:$B$13,0)),"")
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    09-17-2014
    Location
    Cambridge, England
    MS-Off Ver
    2016
    Posts
    58

    Re: Formula/VBA to Vlookup multiple values both horizontally and vertically

    Belinda200 - your solution worked perfectly thank you.

    Thanks for your help everyone.

  5. #5
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: Formula/VBA to Vlookup multiple values both horizontally and vertically

    Thanks for letting me know, you're welcome.

+ 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] Trying to sumif(s) values using Lookup vertically and horizontally
    By AlanaT in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-25-2016, 12:49 PM
  2. Show column header values vertically vs. horizontally in pivot results
    By Scott1807 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 05-29-2015, 04:39 AM
  3. [SOLVED] Returning values from another sheet which works when dragged horizontally and vertically
    By letstuffhappen in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-06-2015, 01:22 PM
  4. look-up values horizontally and reflect them vertically
    By Ksenia in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-30-2014, 01:52 PM
  5. VBA, Vlookup with Multiple Values Vertically
    By splash_b in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 02-23-2014, 09:13 PM
  6. [SOLVED] Vlookup on Dynamic Range that expands vertically and horizontally
    By huy_le in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-27-2013, 03:47 PM
  7. Replies: 8
    Last Post: 06-19-2012, 06:02 AM

Tags for this Thread

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