+ Reply to Thread
Results 1 to 5 of 5

Determine Largest Variable

  1. #1
    Registered User
    Join Date
    02-23-2015
    Location
    ottawa, canada
    MS-Off Ver
    2003
    Posts
    2

    Determine Largest Variable

    Hello,

    Fairly new to Excel VBA programming and could use some help.

    I have 11 variables that will vary in their quantity.

    What is the easiest way to determine which of the 11 is the greatest?

    The variable names I have are as follows: ac_prod, cc_prod, cran_prod, pb_prod, ss_prod, csa_prod, granola_prod, nuttyap_prod, tm_prod, sac_prod, ms_prod

    I did spend some time searching for a similar post but did not find anything relevant to my situation.

    Thank you for your help.

    Kyle

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,696

    Re: Determine Largest Variable

    It would be easier to do this if these values were in an array, or if they were values in a range in a worksheet. How are you getting the values into these variables in the first place? It would be helpful to have your code.

    What are you going to do with it once you find out which one is the maximum? Do you really need to know which variable is greatest, or just what is the greatest value?
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    02-23-2015
    Location
    ottawa, canada
    MS-Off Ver
    2003
    Posts
    2

    Re: Determine Largest Variable

    The values of the varaibles are determined by summing vertically (columns) based on inputs from another workbook.

    Yes, I need to know which variable is the greatest.

    Displaying the variable name in a msgbox would suffice for this demo.

    Thank you

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,696

    Re: Determine Largest Variable

    You didn't say what the data types are for your variables. This assumes they are Long. It's brute force, there's no better way unless we know more details about how the variable values are set.

    Please Login or Register  to view this content.

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,430

    Re: Determine Largest Variable

    Slight variation to handle ties.

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

+ 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. Determine largest value in column 2 for index in column 1
    By anakaine in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-19-2013, 11:26 PM
  2. Using a variable to determine Row
    By aare001 in forum Excel General
    Replies: 3
    Last Post: 02-09-2011, 02:45 AM
  3. Determine Largest Value
    By Kaziglu Bey in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-26-2009, 01:26 PM
  4. determine a variable's value then use it in another procedure
    By carsto in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-19-2007, 06:33 PM
  5. How can I determine the largest physical size cell in a column
    By csa001 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-22-2006, 10:00 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