Results 1 to 3 of 3

VBA: How to create a function to divide the smallest number by the largest within a range

Threaded View

mathgirl09 VBA: How to create a function... 06-03-2015, 02:04 PM
zbor Re: VBA: How to create a... 06-03-2015, 02:07 PM
zbor Re: VBA: How to create a... 06-03-2015, 02:50 PM
  1. #1
    Registered User
    Join Date
    06-03-2015
    Location
    Canada
    MS-Off Ver
    2011
    Posts
    1

    VBA: How to create a function to divide the smallest number by the largest within a range

    Hi, I'd like to know how to create a function by selecting a range (A1 to A30) and for the function to select the smallest number to divide by the largest one.
    Example:
    A1 50
    A2 48
    A3 45
    A4 44
    A5 40
    A6 38
    A7 30


    I want my function to select A1 and A2 and divide A2 by A1 (48/50). I tried:

    Function ratio(ByVal nb1 As Single, ByVal nb2 As Single) As Single
    If nb2 > nb1 Then
      ratio = nb1 / nb2
    Else
      Choose nb2 > nb1
    
    End If
    End function
    It didn't work
    Last edited by zbor; 06-03-2015 at 02:50 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Output one instance of the smallest AND largest value in a range
    By dchubbock in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-09-2013, 04:08 PM
  2. Excel 2007 : sort smallest number to largest
    By ravihotwok in forum Excel General
    Replies: 1
    Last Post: 12-06-2011, 11:35 AM
  3. % of difference between smallest and largest #s in a range
    By jomili in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-06-2010, 08:03 AM
  4. Returning the Nth Largest / Smallest Values in a Range
    By ExcelTip in forum Tips and Tutorials
    Replies: 0
    Last Post: 08-29-2005, 07:53 AM
  5. Getting the 2nd largest or smallest valuesin a range
    By Michael Rekas in forum Excel General
    Replies: 5
    Last Post: 01-31-2005, 04:06 AM

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