+ Reply to Thread
Results 1 to 14 of 14

Find the highest value and return adjacent cell until value changes in another cell

  1. #1
    Registered User
    Join Date
    11-20-2022
    Location
    USA
    MS-Off Ver
    MS 365
    Posts
    12

    Find the highest value and return adjacent cell until value changes in another cell

    I am an excel novice, so I hope I am explaining my problem well enough:

    Capture.JPG

    Field A is the District the candidate is running in, Field B is the candidate name, Field C is the percent of the vote the candidate received, and I need Field D to calculate the District winner's name.

    I am trying to calculate the name of the District winner into Field D until the District changes. I know there is probably a much better way to do what I am trying to do, but here is the formula I have pieced together so far: =IF(A2="",A1,A2 (INDEX(B2:B3,0,MATCH(MAX(C2:C3),C2:C3,0))))

    Any help is appreciated!

  2. #2
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,419

    Re: Find the highest value and return adjacent cell until value changes in another cell

    An option:

    Please try
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    If the score is tied, multiple winners will be shown.
    Attached Files Attached Files
    Last edited by HansDouwe; 11-20-2022 at 01:26 AM.

  3. #3
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Find the highest value and return adjacent cell until value changes in another cell

    Hi roquinn and welcome to the forum,

    A formula like:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    is what I came up with. See it in the attached and adjust to your sheet.
    XLookup from Max Filtered.xlsx
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  4. #4
    Registered User
    Join Date
    11-20-2022
    Location
    USA
    MS-Off Ver
    MS 365
    Posts
    12

    Re: Find the highest value and return adjacent cell until value changes in another cell

    That worked perfectly. I do have another question - is there a way to only return the winner in column D? This way I would be able to count how many times the candidate won.

  5. #5
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Find the highest value and return adjacent cell until value changes in another cell

    Hi roquin,

    Try this extended formula to only show one name for the winner:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    XLookup from Max Filtered One Name.xlsx

  6. #6
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    Australia
    MS-Off Ver
    365 V2403 and WPS V2022
    Posts
    3,408

    Re: Find the highest value and return adjacent cell until value changes in another cell

    ans #1

    Cell D2 formula , Drag down

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  7. #7
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    Australia
    MS-Off Ver
    365 V2403 and WPS V2022
    Posts
    3,408

    Re: Find the highest value and return adjacent cell until value changes in another cell

    @roquinn You're Welcome. Glad to help . Thank You for the feedback and rep.

    If you finally get a solution please mark your thread as SOLVED:
    - Click Thread Tools above your first post,you will see the word PREFIX on the upper left, press the button to select [SOLVED] select "Mark your thread as Solved".
    Last edited by wk9128; 11-20-2022 at 12:12 PM.

  8. #8
    Registered User
    Join Date
    11-20-2022
    Location
    USA
    MS-Off Ver
    MS 365
    Posts
    12

    Re: Find the highest value and return adjacent cell until value changes in another cell

    Hey Marvin,

    Thank you for looking into this! So on my spreadsheet, the fields are dist=AH, candidate=AQ, percent=AR going all the way to row 2729. When I change the field values to match the formula you shared down, I get a #N/A error. I even copied the three columns from my spreadsheet into the corresponding columns on the sample spreadsheet you sent and it works for the first 15 cells, then I get a #Calc error. I am not sure what I am doing wrong.

  9. #9
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Find the highest value and return adjacent cell until value changes in another cell

    Hi roquinn,

    There are a few possible reasons my formula didn't work for you. The first possible reason is the data changed by have a space before or after it. Check to see if the data is exactly the same of what you have and what you are looking for. Second is that you've left off a dollar sign in one of the formulas. Another possible reason is you didn't change the formula to go to your last row.

    To figure out what went wrong for you, we'd need a sample of your data in an attached workbook.

  10. #10
    Registered User
    Join Date
    11-20-2022
    Location
    USA
    MS-Off Ver
    MS 365
    Posts
    12

    Re: Find the highest value and return adjacent cell until value changes in another cell

    Here is a sample of my polling data. It has the HouseHistorical and the SenateHistorical data samples.

    HouseHistoricPolls.xlsx

    Thanks!

  11. #11
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,419

    Re: Find the highest value and return adjacent cell until value changes in another cell

    You entered the formula correctly, but The #NA error is caused by cells AH69 through AH73 containing #N/A.
    These cells must contain a district.
    So yet another cause than one of the possibilities mentioned by Marvin.

  12. #12
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Find the highest value and return adjacent cell until value changes in another cell

    Hi roquin,

    Thanks to Hans for the explanation.

    It looks like you have a #N/A in column L of your sheet which is the original cause of the problem.

    Thanks for posting more of your work. As you can imagine, finding the real cause of problems needs lots of detective work.

  13. #13
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    Australia
    MS-Off Ver
    365 V2403 and WPS V2022
    Posts
    3,408

    Re: Find the highest value and return adjacent cell until value changes in another cell

    In fact, the problem lies in the column AH , and the problem is solved by changing the original formula a little.

    Cell AH2 formula , Drag down

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Cell AS2 formula , Drag down

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  14. #14
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Find the highest value and return adjacent cell until value changes in another cell

    Good catch!!

+ 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. Find value and return adjacent cell value
    By chrisellis250 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 06-28-2019, 07:29 AM
  2. Replies: 3
    Last Post: 07-21-2015, 05:10 PM
  3. Replies: 9
    Last Post: 03-04-2015, 11:41 PM
  4. [SOLVED] Formula to find lowest/highest value in a column and return value to that cell
    By maryren in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-25-2013, 11:21 AM
  5. [SOLVED] Find highest value in unsorted column and return data of other cell
    By vergrootglas in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 10-07-2012, 11:56 AM
  6. [SOLVED] Find cell value and return even number on adjacent cell
    By Surya51 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-29-2012, 01:03 PM
  7. Referencing adjacent cell to return highest figure
    By Alex G in forum Excel General
    Replies: 12
    Last Post: 05-11-2010, 04:07 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