+ Reply to Thread
Results 1 to 4 of 4

How to reference sequence of rows with matching value

  1. #1
    Registered User
    Join Date
    07-09-2016
    Location
    las vegas, nevada
    MS-Off Ver
    2010
    Posts
    2

    How to reference sequence of rows with matching value

    My ultimate goal is to change the format of the spreadsheet in order to use it for a mail merge. Unfortunately, the data comes from a database file, and the available format of the data does not support my needs or the capability of Word.

    Here is the initial format [sheet 1]
    B
    A1 JOHN RED
    A2 JOHN BLUE
    A3 JOHN YELLOW
    A4 SUE ORANGE
    A5 SUE GREEN
    A6 BOB PURPLE

    For the mail merge I need to be able to reference all data associate with a person's name (Ex: JOHN DOE: red, yellow, orange) but Word can't recognize fields from different records (rows). Therefore, I need to convert the data to the following format:

    [sheet 2]
    B C D
    A1 JOHN RED BLUE YELLOW
    A2 SUE ORANGE GREEN
    A3 BOB PURPLE

    Being that there are over 400+ lines of data, I can't simply cut and paste or reorganize easily. I need something automated on sheet 2. I can sort sheet 1 and easily reference the 1st name. From there,

    1) how do you search sheet 1 for each subsequent matching name and reference data in column B.
    2) how do you look for the next name change on sheet 1 to begin data search on sheet2- A2?

    **note I can always use remove duplicate on sheet 1 to be able to cut and paste all singular names into sheet 2 if absolutely necessary, but I would like something a bit more automated.

  2. #2
    Registered User
    Join Date
    07-09-2016
    Location
    las vegas, nevada
    MS-Off Ver
    2010
    Posts
    2

    Re: How to reference sequence of rows with matching value

    FYI---

    I know I can use VLOOKUP and get the first reference as long as I have a name in A1 (John)

    =VLOOKUP($A1,Sheet1!A:B,2,FALSE)
    result RED


    1) How to I reference the next values for JOHN (blue and yellow)
    2) If I don't want to prepopulate A2, how to I fill with the next name in the sequence (SUE)

  3. #3
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,844

    Re: How to reference sequence of rows with matching value

    If you post a workbook with some sample data it will be much easier to help you.
    <----- If you were helped by my posts you can say "Thank you" by clicking the star symbol down to the left

    If the problem is solved, finish of the thread by clicking SOLVED under Thread Tools
    I don't wish to leave you with no answer, yet I sometimes miss posts. If you feel I forgot you, remind me with a PM or just bump the thread.

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: How to reference sequence of rows with matching value

    Try this...

    Data Range
    A
    B
    C
    D
    E
    F
    G
    H
    1
    2
    John
    Red
    John
    Red
    Blue
    Yellow
    3
    John
    Blue
    Sue
    Orange
    Green
    4
    John
    Yellow
    Bob
    Purple
    5
    Sue
    Orange
    6
    Sue
    Green
    7
    Bob
    Purple
    8
    ------
    ------
    ------
    ------
    ------
    ------
    ------
    ------


    This array formula** entered in E2:

    =IFERROR(INDEX($B:$B,SMALL(IF($A$2:$A$7=$D2,ROW(A$2:A$7)),COLUMNS($E2:E2))),"")

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

    Copy down as needed then across until you get a column full of blanks.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

+ 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] Add total of two rows within a column with matching reference numbers
    By steve_Smart in forum Excel General
    Replies: 5
    Last Post: 09-20-2014, 03:41 AM
  2. Index for Sequence Matching or how close is the match
    By sajeel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-26-2013, 05:59 AM
  3. [SOLVED] Drag Sequence having sheet reference
    By am_hawk in forum Excel General
    Replies: 3
    Last Post: 10-04-2013, 03:33 PM
  4. Identifying last sequence reference number
    By coopedup in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-28-2013, 09:33 AM
  5. Replies: 2
    Last Post: 05-22-2012, 08:50 PM
  6. [SOLVED] UDF to return string of values of all rows with cell matching reference cell
    By oemgacaesar in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-20-2012, 12:43 PM
  7. [SOLVED] out of sequence reference
    By Addy in forum Excel General
    Replies: 2
    Last Post: 12-31-2005, 02:04 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