+ Reply to Thread
Results 1 to 12 of 12

Macros - find largest number in range

  1. #1
    Registered User
    Join Date
    06-24-2009
    Location
    NV
    MS-Off Ver
    Excel 2003
    Posts
    34

    Macros - find largest number in range

    How to automate the process of finding the highest number in a dynamic range meeting a criteria?

    New data added/updated every day (new come, old gone).

    The attached file has a properly displayed data.

    Thanks,
    hmgrts
    Attached Files Attached Files
    Last edited by hmgrts; 07-09-2009 at 02:21 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macros - find largest number in range

    Give this macro a try. Be sure to remove those notes off to the right or it will interfere with the "find" commands.
    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 07-08-2009 at 03:05 PM. Reason: Removed the LOOP, replaced with a single MAX calculation
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    06-24-2009
    Location
    NV
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: Macros - find largest number in range

    Thank you very much JBeaucaire.

  4. #4
    Registered User
    Join Date
    06-24-2009
    Location
    NV
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: Macros - find largest number in range

    I'm getting "Run-time error '91': Object veriable or With block variable not set" If I'm changing

    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.
    How to fix it?

    Thanks,
    hmgrts

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macros - find largest number in range

    Repost your sheet with the corrected data and your corrected needs, I'll take a look.

  6. #6
    Registered User
    Join Date
    06-24-2009
    Location
    NV
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: Macros - find largest number in range

    Here is sheet with corrected data:
    Attached Files Attached Files

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macros - find largest number in range

    1) You have the macro in the wrong place. In the VBEditor, click on INSERT > MODULE and place the regular macro into a regular module.

    2) Put the code back exactly the way it was when I gave it to you. It works fine with this data, too. The 15:00 is a visual number format, it's still 3:00:00 PM in the cell, so the macro can find the 3:00 just fine.

    3) Make sure you remove all the "notes" you put in off to the right, they WILL interfere with the macro.

  8. #8
    Registered User
    Join Date
    06-24-2009
    Location
    NV
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: Macros - find largest number in range

    2) Put the code back exactly the way it was when I gave it to you. It works fine with this data, too. The 15:00 is a visual number format, it's still 3:00:00 PM in the cell, so the macro can find the 3:00 just fine.
    Yes, macro can find the 3:00 PM just fine but it's also picking 3:00 AM.

  9. #9
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macros - find largest number in range

    The first data set had only 3:00 AM, and the macro works great.
    The second data set had only 3:00 PM and the macro works as designed.

    Is there a reason you haven't simply presented a dataset with ALL the parameters and times needing to be dealt with and supplied sample results from that data?

  10. #10
    Registered User
    Join Date
    06-24-2009
    Location
    NV
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: Macros - find largest number in range

    I wanted to simplify.

    This is file with all the parameters and times:
    Attached Files Attached Files

  11. #11
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macros - find largest number in range

    Ah, ok, simple enough. Just change the 3:00 to 3:00:00 AM and it will return to expected operation.
    Please Login or Register  to view this content.
    It's always best to work with the actual data instead of simplified versions. From our point of view, we presume you are presenting all the parameters and our suggestions/methods are affected...and may be incorrect based on what you might have left out.

    Anyway, this is good to go, yes? If that takes care of your need, be sure to EDIT your original post, click Go Advanced and mark the PREFIX box [SOLVED].


    (Also, use the blue "scales" icon in our posts to leave Reputation Feedback, it is appreciated)

  12. #12
    Registered User
    Join Date
    06-24-2009
    Location
    NV
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: Macros - find largest number in range

    Yes, this is good. Thank you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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