+ Reply to Thread
Results 1 to 5 of 5

VBA Function to Find Value Matching the Max Value

  1. #1
    Registered User
    Join Date
    03-06-2017
    Location
    London, Canada
    MS-Off Ver
    Microsoft Office 2016
    Posts
    5

    VBA Function to Find Value Matching the Max Value

    I need to create a VBA function that takes in two arrays; the first array has the numeric values while the second array has the names. The function will find the value in the first array that is the largest and return the corresponding name (from the second array). However, I cannot use the Max function within my created function. The function also needs to begin like this:

    Function FindMax(valueArray, nameArray) As String

    Thanks for any help you can provide.

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: VBA Function to Find Value Matching the Max Value

    May I ask why you can't use the max function?
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Registered User
    Join Date
    03-06-2017
    Location
    London, Canada
    MS-Off Ver
    Microsoft Office 2016
    Posts
    5

    Re: VBA Function to Find Value Matching the Max Value

    That was just one of the stipulations within the question given to me. But an answer using the Max function would be helpful for my understanding as well

  4. #4
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: VBA Function to Find Value Matching the Max Value

    I assume the 2 arrays have the same number of elements? and there is a reliationship between valuearray(n) and namearray(n)?

    See if this works:

    Please Login or Register  to view this content.

  5. #5
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: VBA Function to Find Value Matching the Max Value

    I did try something with the max function, but it didn't work as I expected, which is why I didn't post that one.
    Thanks for the rep I assume it worked out for you? Please remember to mark the thread as solved if you are satisfied with the solution? Thanks

+ 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. [SOLVED] How to find the last matching value or before the last one?
    By stoicy in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 04-13-2016, 04:46 PM
  2. Replies: 1
    Last Post: 09-30-2015, 11:37 PM
  3. Replies: 2
    Last Post: 04-11-2013, 11:14 AM
  4. Replies: 11
    Last Post: 08-14-2012, 07:58 PM
  5. [SOLVED] Find matching words in 10 columns and add row numbers of matching words
    By zeke 29 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 08-03-2012, 09:57 AM
  6. Find Matching Value
    By infinitysales in forum Excel General
    Replies: 2
    Last Post: 09-18-2009, 02:39 PM
  7. Replies: 1
    Last Post: 04-15-2009, 01:42 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