+ Reply to Thread
Results 1 to 6 of 6

How to return cell value based on number of occurences

  1. #1
    Registered User
    Join Date
    10-03-2016
    Location
    Prague
    MS-Off Ver
    2010
    Posts
    7

    How to return cell value based on number of occurences

    Hello, I would like to ask you for a help. For lack of a better explanation I chose to entitled the problem "returning cell value based on number of occurences" which might be incorrect description. Anyway, here is the problem.

    In my workbook I have eleven sheet. In the first sheet, there is a schedule of matches of teams and the rest ten sheets are each for individual team. The schedule sheet has following notation:

    A B C
    1 5.9.2016 Team A Team B
    2 5.9.2016 Team C Team D
    ...
    6 20.9.2016 Team C Team A


    The sheet for the team A has following notation:

    A B
    1 Order of a game 1
    2 Date of a game 5.9.2016
    3 Opponent Team B
    4 Venue H
    ...
    41 Order of a game 2
    42 Date of a game 20.9.2016
    43 Opponent Team C
    44 Venue R

    Now, I would like to automatically and as simple as possible get value of an opponent team (B3, B43,..) based on schedule sheet (C1, B6). My idea was to calculate the order number of a game for a given team in schedule sheet (by COUNT) and compare it to order number in an individual sheet (B1, B41) and then return the value a an opponent. I am stuck, however. Could you please help me?

    Note: A date of a game and venue values are not present in a team sheet. Those values are to be returned from the schedule sheet as well.
    Last edited by jeffjam; 10-03-2016 at 04:15 AM.

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,733

    Re: How to return cell value based on number of occurences

    Rather than reproduce what you have given before being able to try things out, it would help if you attached a sample Excel workbook.

    To do this, click on Go Advanced (below the Edit Window) while you are composing a reply, then scroll down to and click on Manage Attachments and the Upload window will open. Click on Browse and navigate to (and double-click) the file icon that you want to attach, then click on Upload and Close this Window to return to the Edit window. When you have finished composing your post, click on Submit Post.

    Pete

  3. #3
    Registered User
    Join Date
    10-03-2016
    Location
    Prague
    MS-Off Ver
    2010
    Posts
    7

    Re: How to return cell value based on number of occurences

    Ok, I am sending the example workbook with the described layout. I am having problem getting values to B3,B4,B5...B44,B45,B46 cells in individual team sheets based on Schedule sheet while using order of a game at cell B2, B43.
    Attached Files Attached Files

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,733

    Re: How to return cell value based on number of occurences

    First of all, I changed your formula in AO4 of the Schedule sheet to this:

    =IF(A4="","",VLOOKUP(B4,$AR$4:$AT$15,3,0))

    and the one in AP4 to this:

    =IF(A4="","",VLOOKUP(C4,$AR$4:$AT$15,3,0))

    as they are much shorter. Then I put this formula in AM4 (coloured blue):

    =IF(AO4="","",AO4&"_"&COUNTIF(AO$4:AP4,AO4))

    and this one in AN4 (also blue):

    =IF(AP4="","",AP4&"_"&COUNTIF(AO$4:AP4,AP4))

    All of these were copied down to row 156.

    Then in the individual team sheets I put the 3-letter code for the team (also the sheet name) in cell A1, and these formulae in the cells stated:

    B3: =IFERROR(INDEX(Schedule!$A:$A,MATCH($A$1&"_"&B2,Schedule!AM:AM,0)),IFERROR(INDEX(Schedule!$A:$A,MATCH($A$1&"_"&B2,Schedule!AN:AN,0)),""))

    B4: =IF(COUNTIF(Schedule!$AM:$AM,$A$1&"_"&B2),"H",IF(COUNTIF(Schedule!$AN:$AN,$A$1&"_"&B2),"R",""))

    B5: =IF(B4="H",INDEX(Schedule!$C:$C,MATCH($A$1&"_"&B2,Schedule!$AM:$AM,0)),INDEX(Schedule!$B:$B,MATCH($A$1&"_"&B2,Schedule!$AN:$AN,0)))

    That block of 3 cells can be copied into B44:B46, as well as into the corresponding cells of the other team sheets.

    Hope this helps.

    Pete
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    10-03-2016
    Location
    Prague
    MS-Off Ver
    2010
    Posts
    7

    Re: How to return cell value based on number of occurences

    That is wonderful, thank you very much. You helped me a lot. Can I buy you a daiquiri or two?

  6. #6
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,733

    Re: How to return cell value based on number of occurences

    Glad to help.

    You know, you are the second person on here to offer me a drink in the last week (mind you, the other offer was for a beer). Of course, we give our help for free, so the only thing I would ask is for you to click on the "star" icon ("Add Reputation") in the bottom left corner of a post that you have found to be helpful - you can also leave a (private) comment if you wish to. You can do this in other threads that you find useful, as a way of "rewarding" the contributors.

    Hope this helps.

    Pete

+ 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. Return Max Number of Consecutive Occurences of '4' or More
    By Brumbot in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-14-2014, 12:00 PM
  2. Trying to Return a Number in a Cell based on Text
    By jslavinsky in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 07-01-2014, 11:23 PM
  3. Count Number of occurences Across Columns based on Similar Column Headers
    By vidyuthrajesh in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-27-2013, 06:42 PM
  4. Count number occurences based on criteria Column
    By SamCrome in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-04-2013, 04:32 PM
  5. [SOLVED] Return number based on two cell inputs
    By NZK in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-03-2013, 09:09 PM
  6. [SOLVED] Calculating number of occurences based on dates
    By Henrik Fritsche in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-23-2006, 11:15 AM
  7. [SOLVED] number of character occurences in a cell
    By Ron in forum Excel General
    Replies: 1
    Last Post: 03-21-2005, 01:06 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