+ Reply to Thread
Results 1 to 8 of 8

Find exact match, and the closest smallest and highest numbers.

  1. #1
    Forum Contributor
    Join Date
    12-12-2017
    Location
    New Zealand
    MS-Off Ver
    MS 365
    Posts
    517

    Lightbulb Find exact match, and the closest smallest and highest numbers.

    Hello all,

    I am looking to get a macro for the results I have in cols BJ:BO. I have resulted the first 5 x names by filter.

    To explain I will go to the name Billy Bunter as he has all expected results for all 6 x cols BJ:BO.

    Each name is in ascending order by date, the oldest date to the newest date.
    Col AP is counting how many starts each name has had.
    Col BG is the number of days since each names last run, so this is looking back at the date of their last run and resulting how many days.
    Each name is individual, and the results only refer to that one name.
    There are names in here that have had only one start, so col BG will be 0, zero. There will not be any results in cols BJ:BO as there is nothing to refer back to.
    The results in col BJ:BO are always referencing back over each name past history only.

    Exact finish and exact margin.
    Here we see Billy has in cell BG25 the number 11, this is an exact match in cell BG20, so results come from cols AL and AO. 4 and 3.3

    Lower finish and lower margin.
    This is looking back for the next smallest number in col BG.
    Cell BG19 says 45, so looking back there is only one run, cell BG18 says 0, zero. So, results come from cols AL and AO being 15 and 8.6

    Higher finish and Higher margin.
    This is doing the same thing, except its looking for the closest number that is higher than the number in col BG.
    Cell BG24 is 49, so the closest highest number to 49 is 109 in cell BG22. result in cols BN and BO are 5 and 3.5

    I think I have explained everything, but I have a record of leaving things out, happy to take all questions and I hope I can get a result.
    I have 580,000 rows to process, and I know some macros need time to work, I'm happy to let computer do its thing.

    Thanks.
    Attached Files Attached Files
    I am grateful for all answers to my questions .
    Also i give a reputation even if not answered .

  2. #2
    Valued Forum Contributor
    Join Date
    02-04-2017
    Location
    chennai
    MS-Off Ver
    MS OFFICE 365
    Posts
    440

    Re: Find exact match, and the closest smallest and highest numbers.

    I can help you create a VBA macro for this task. It seems like you want to analyze data in columns BJ to BO for each individual name, considering conditions related to the values in column BG.

    Here's a sample VBA macro that you can use as a starting point. Please note that this is a basic example, and you may need to adapt it based on your specific requirements:
    Please Login or Register  to view this content.
    Last edited by AliGW; 12-16-2023 at 03:16 AM. Reason: Please do NOT quote unnecessarily! Use the QUICK REPLY button instead.

  3. #3
    Forum Contributor
    Join Date
    12-12-2017
    Location
    New Zealand
    MS-Off Ver
    MS 365
    Posts
    517

    Re: Find exact match, and the closest smallest and highest numbers.

    Thanks for your result. I put the code into sheet, see example v2, version, 2.

    But nothing is resulting, cols BJ:BO are blank when I run your code. Maybe I'm doing something wrong.
    Appreciate time spent writing this.
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor
    Join Date
    02-04-2017
    Location
    chennai
    MS-Off Ver
    MS OFFICE 365
    Posts
    440

    Re: Find exact match, and the closest smallest and highest numbers.

    Dear I need excel help
    kindly update this code Here's an updated version of the code, with placeholders for the calculations. Please replace the placeholders with your actual logic:
    Please Login or Register  to view this content.
    Make sure you replace the placeholder logic with your actual calculations. If you encounter any specific issues or have further questions, feel free to let me know.

  5. #5
    Forum Contributor
    Join Date
    12-12-2017
    Location
    New Zealand
    MS-Off Ver
    MS 365
    Posts
    517

    Re: Find exact match, and the closest smallest and highest numbers.

    I'm a bit thick and don't understand replace the placeholder logic.
    I can only paste the code into a new module and that's my limit. This is what I normally do to a lack of skills in vba.

    I can see massive effort in writing this, please excuse my inability to understand where I should paste above new part of code.

    Can you post the whole code so I can copy and paste into a module.

    Thanks.
    Last edited by I need excel help; 12-17-2023 at 05:37 AM.

  6. #6
    Forum Contributor
    Join Date
    12-12-2017
    Location
    New Zealand
    MS-Off Ver
    MS 365
    Posts
    517

    Re: Find exact match, and the closest smallest and highest numbers.

    Hello, thanks for the code you have written.
    Can you or someone post the whole macro to work on the sheet. I do not understand the two posts of code, how do they join, where do they join, vba is way over my head.

    I have spent hours trying to get the code to work but no joy.
    Thanks.

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,301

    Re: Find exact match, and the closest smallest and highest numbers.

    Bump for visibility.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  8. #8
    Forum Contributor
    Join Date
    12-12-2017
    Location
    New Zealand
    MS-Off Ver
    MS 365
    Posts
    517

    Re: Find exact match, and the closest smallest and highest numbers.

    Bumped for visibility.

    Cross post. Which I appear to be failing at.
    [https://www.mrexcel.com/board/thread...bers.1250627/]

    Thanks, AliGW, I have re-read the rules, and I will follow these exactly.
    Thanks.
    Last edited by I need excel help; 12-18-2023 at 03:12 PM.

+ 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 closest or exact match on 2 criteria
    By zlr1910 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-06-2020, 07:42 AM
  2. Find exact match or closest value in between two columns
    By amberle in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-19-2017, 11:12 AM
  3. Index Match to find smallest 6 numbers problem
    By minto in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-17-2015, 05:48 AM
  4. Replies: 4
    Last Post: 04-01-2015, 01:51 PM
  5. Replies: 3
    Last Post: 04-30-2012, 09:28 AM
  6. [SOLVED] find closest match to a reference number in a row of numbers
    By Nick Krill in forum Excel General
    Replies: 4
    Last Post: 12-21-2005, 08:00 AM
  7. Replies: 0
    Last Post: 08-25-2005, 02:37 AM

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