+ Reply to Thread
Results 1 to 5 of 5

Find the last occurrence of a value in multiple columns or a matrix

  1. #1
    Registered User
    Join Date
    03-27-2014
    Location
    Las Vegas, Nevada
    MS-Off Ver
    Excel 2013
    Posts
    12

    Find the last occurrence of a value in multiple columns or a matrix

    I have a spreadsheet that tracks hymns for given date. A simplified verion of it look like this:

    A B C D E F G H I
    1 Date Chorister Organist Hymn #1 Hymn #1 Title Hymn #2 Hymn #2 Title Hymn #3 Hymn #3 Title
    2 Oct 19, 2014 Joe Jane 140 Lorem ipsum 190 dolor sit amet 19 consectetur
    3 Oct 26, 2014 Jack Jenny 144 adipiscing elit 191 Vivamus dui nisl 141 elementum id
    4 Nov 2, 2014 Jeff Jill 229 sodales sit amet 192 rutrum nec justo 107 Sed sollicitudin
    5 Nov 9, 2014 John Joyce 94 diam nec tempus 193 adipiscing 237 nisi elit
    6 Nov 16, 2014 Jim Janet 21 malesuada 194 nulla, quis 231 congue velit
    7 Nov 23, 2014 Jake Jacqueline 93 arcu et mauris 195 Vestibulum 96 et egestas
    8 Nov 30, 2014 Jared June 210 ipsum 202 Aliquam 92 nisl metus
    9 Dec 7, 2014 Jason Jean 212 pellentesque 197 ac nulla id, 211 posuere
    10 Dec 14, 2014 Jed Jessica 209 semper nisl 146 In purus dui, 213 varius sed
    11 Dec 21, 2014 Jesse Johanna 205 posuere ut 169 suscipit et magna 208 Ut suscipit
    12 Dec 28, 2014 Josh Julie 207 sed sem 170 ut consequat 202 Curabitur


    On a separate sheet I have a spreadsheet of which a simplified version which should eventually look like this:
    E F G H
    1 Hymn # Title Last Sung (date) # of Times Sung
    2 201 Lorem
    3 202 ipsum Dec 28, 2014 2
    4 203 dolor
    5 204 sit amet
    6 205 consectetur Dec 21, 2014 1
    7 206 adipiscing elit
    8 207 Vivamus Dec 28, 2014 1
    9 208 dui nisl Dec 21, 2014 1
    10 209 elementum Dec 14, 2014 1

    First, I'm looking for a formula that will look at the matrix in the first sheet, find the last occurrence of the corresponding hymn # from the second spread sheet, and then copy the date from the corresponding row in column A of the first spreadsheet to the appropriate cell in column G on the second spreadsheet.

    Second, I'm looking for a formula that will look at the matrix in the first sheet, count the total number of times a given hymn # appears, and then place that total in the appropriate cell in column H on the second spread sheet. (This helps me spot duplicates.)

    I've tried using various combinations of SUMPRODUCT, MAX, ROW, INDEX, and SUMIFS, but can't seem to get the anything but errors.

    Any help would be appreciated.

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,612

    Re: Find the last occurrence of a value in multiple columns or a matrix

    To attach a Workbook
    (please do not post pictures of worksheets)
    • Click Advanced (next to quick post),
    • Scroll down until you see "Manage Attachments",
    • Click that then select "add files" (top right corner).
    • Click "Select Files" find your file, click "open" click "upload"
    • Once the upload is completed the file name will appear below the input boxes in this window.
    • Click "Done" at bottom right to close the Attachment Manager.
    • Click "Submit Reply"
    Ben Van Johnson

  3. #3
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: Find the last occurrence of a value in multiple columns or a matrix

    Something like this?
    Attached Files Attached Files
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  4. #4
    Registered User
    Join Date
    03-27-2014
    Location
    Las Vegas, Nevada
    MS-Off Ver
    Excel 2013
    Posts
    12

    Re: Find the last occurrence of a value in multiple columns or a matrix

    Once I adjust the references in the live worksheet, I get unexpected results. It is supplying a date for every hymn regardless of whether it was scheduled or not.

    HymnTrack.xlsx
    Last edited by jbh001; 06-30-2014 at 04:56 PM.

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

    Re: Find the last occurrence of a value in multiple columns or a matrix

    Yes and the wrong dates as well. The row function gives the absolute row with no regards to any "sub-range", hence the final INDEX function needs to start at row 1 to provide the correct result.

    The dates where there should be no dates comes from the array being filled with zeroes because there was no match. MAX of a bunch of 0's is 0. 0 as a row input to the INDEX function actually tells it to provide not a single row but all the rows but only the first one will be displayed. It may sound inconvenient here but is very useful for other stuff.
    Attached Files Attached Files
    <----- 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.

+ 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: 2
    Last Post: 02-11-2014, 05:05 AM
  2. [SOLVED] Find nth occurrence with multiple criteria
    By Joe Walsh in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-05-2013, 11:09 AM
  3. [SOLVED] Creating a Matrix with Multiple Columns of Data
    By marktickle in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-08-2012, 09:58 PM
  4. Replies: 2
    Last Post: 02-23-2010, 03:01 AM
  5. Replies: 3
    Last Post: 08-20-2009, 06:08 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