+ Reply to Thread
Results 1 to 6 of 6

Lookup from datasets with a single identifier and varying row count

  1. #1
    Forum Contributor
    Join Date
    01-11-2011
    Location
    Frederick, MD, USA
    MS-Off Ver
    Excel 2007
    Posts
    125

    Lookup from datasets with a single identifier and varying row count

    I'm a little bit experienced using the various LOOKUP functions, and can even plod through some INDEX() MATCH() combinations...but I can't figure out a way to pull data from a sheet that has multiple data sets of varying row counts.

    Each data set has a single identifier, then a varying number of rows, with a constant number of columns. Each dataset is listed from top to bottom of the sheet. I'd like to pull specific columns across to another sheet, and arrange these copied data sets horizontally across the sheet.

    Ideally, I'd like to keep this formula-based, because macros have had a history of being forbidden in the regulated environment I'm in. (It's possible that a macro could be approved, but it's doubtful.)

    I've attached an example of what I'm looking for.

    Many thanks in advance to anyone who can answer. Many more thansk to anyone who can answer AND explain it to me like I'm a five year old.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,198

    Re: Lookup from datasets with a single identifier and varying row count

    I think the only solution is VBA because the variability of the data does not lend itself to formulae (which generally prefer regular patterns!)

    For example, finding the text "Sample Name" (to get the sample code) is a problem as Excel "lookups" find the first occurrence of a "match".

  3. #3
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,198

    Re: Lookup from datasets with a single identifier and varying row count

    I appreciate a VBA solution is not your preferred option but here is one anyway. I will see if I can come up with formula-based solution.

    RUN button on first sheet initiates the macro.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,198

    Re: Lookup from datasets with a single identifier and varying row count

    I have added a formula-based solution in sheet "Formulas".

    The cells in A1:C5 are used to determine the row number of the "Sample Name": these are in C2:C4 and in the cells highlighted in yellow. The data in these (yellow) cells is used by the INDEX functions to get the data form the main sheet.

    Formula(s) in A2 down are of the form:

    =IFERROR(MATCH("Sample Name",INDIRECT("'Imported R data'!$A" & B1 &":$A$100"),0),"")

    I use INDIRECT to offset the range used to find the next occurrence of "Sample Name". The value in A is the relative row (position) in the range chosen.

    The data in the tables uses INDEX to get the data:

    =IF(INDEX('Imported R data'!$A$1:$A$100,$E$1+2+ROWS($1:1))="","",INDEX('Imported R data'!$A$1:$A$100,$E$1+2+ROWS($1:1)))
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    01-11-2011
    Location
    Frederick, MD, USA
    MS-Off Ver
    Excel 2007
    Posts
    125

    Re: Lookup from datasets with a single identifier and varying row count

    Thanks, JonTopley! I've fiddled around with your formulae a bit (changing the absolute/relative cell references) to make it easy to copy across multiple columns, and I think I'm starting to understand what the INDIRECT function is doing. I can see how that might become a valuable tool in my toolbox. Thanks again!

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,198

    Re: Lookup from datasets with a single identifier and varying row count

    Thanks for the feedback.

+ 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] Need Pivot for Three Datasets with Count of Yes & No
    By naveeddil in forum Excel Charting & Pivots
    Replies: 10
    Last Post: 07-09-2015, 04:47 AM
  2. [SOLVED] Formula to sum a row if has a single identifier from a drop down
    By pinas in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-22-2014, 06:30 PM
  3. [SOLVED] How to merge two datasets into a single datagrid?
    By Nesin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-20-2013, 02:07 PM
  4. Auto fill fields from a single identifier?
    By grantsmith in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-15-2013, 04:19 PM
  5. Replies: 1
    Last Post: 12-11-2012, 09:06 PM
  6. Convert Datasets of text into a single list
    By Hyflex in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-18-2011, 05:01 AM
  7. Single Column to datasets
    By jeekjee in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-28-2009, 12:27 PM

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