+ Reply to Thread
Results 1 to 1 of 1

Using the LARGE function to adjust the ith largest values

  1. #1
    Registered User
    Join Date
    08-04-2011
    Location
    Sheffield, England
    MS-Off Ver
    Office 2011
    Posts
    1

    Using the LARGE function to adjust the ith largest values

    Hi everyone,

    Excuse the crude post, I am new to VBA (and forums)!
    I am trying to write a program to examine the values in a worksheet column and adjust any values that are larger than a specific criterion value (that is also in the sheet). They have to be adjusted in order so that the highest value is still the highest and the second highest is still the second highest etc.

    Just as a rough example, with the following set of numbers, I would like the code to adjust the values 57 and 60 because they are above the criterion value of 8. 57 Needs to be adjusted to the next highest value (3) and then 60 needs to be adjusted to the value above that (4).

    1
    2
    2
    1
    2
    57
    60

    8


    I thought the best way to do this was to create a variable to count how many values are above the criterion and use this in conjunction with the LARGE function. This way, each value can be selected and adjusted in reference to the next highest value accordingly. The code is as follows...

    Please Login or Register  to view this content.

    There are a couple of issues with this code however.
    Firstly, the LARGE function doesn't seem to like having a variable as its second argument. Also, once the if statement detects one of the high values, the alteration applies to all of the following values even if they are not above the criterion (i.e. every value is adjusted once one of the higher values has been encountered).

    I hope this makes sense I would really appreciate some help/suggestions of a better way to accomplish the task.

    Thanks in advance,
    Kyle
    Last edited by kgbrown; 08-04-2011 at 08:27 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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