+ Reply to Thread
Results 1 to 12 of 12

Check if all values in Array are greater or less than specific value in worksheet

  1. #1
    Forum Contributor
    Join Date
    12-22-2012
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    205

    Check if all values in Array are greater or less than specific value in worksheet

    I used the below code to populate an array with values from active cell up 8 rows. I now want to check if all values in the array are either greater than or less than a specific value in worksheet, let's say the check value resides in cell "A1" for simplicity.

    Any help would be greatly appreciated.

    Please Login or Register  to view this content.
    Last edited by jprlimey; 01-25-2017 at 08:45 AM. Reason: Solved

  2. #2
    Valued Forum Contributor kasan's Avatar
    Join Date
    07-22-2009
    Location
    Riga, Latvia
    MS-Off Ver
    Excel 2010
    Posts
    680

    Re: Check if all values in Array are greater or less than specific value in worksheet

    Put value from cell in some variable and then loop through array and compare, like this:
    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Check if all values in Array are greater or less than specific value in worksheet

    I take it you want a single result like TRUE/FALSE rather than each individual? ie if 7 of the 8 are greater than A1 then its FALSE but if all 8 are then TRUE?

    Do you need the data in an array for something else or was it just put in there to do this task because
    Please Login or Register  to view this content.
    would give you the answer directly from the range
    If someone has helped you then please add to their Reputation

  4. #4
    Forum Contributor
    Join Date
    12-22-2012
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    205

    Re: Check if all values in Array are greater or less than specific value in worksheet

    Yes, I'm triggering the check on an Worksheet_Change event

    Yes I only want the MsgBox to display when ALL values in array are greater than A1

  5. #5
    Forum Contributor
    Join Date
    12-22-2012
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    205

    Re: Check if all values in Array are greater or less than specific value in worksheet

    kasan,

    I tried your suggestion. It did loop thru the array to check the value in cell "A1" against array values. However it returned the MsgBox for each occurrence of the array value being > than "A1" value. What I need is MsgBox when ALL records in array > value in cell "A1"

    Thanks


    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    12-22-2012
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    205

    Re: Check if all values in Array are greater or less than specific value in worksheet

    Still trying to solve this, does anyone else have more input?

  7. #7
    Valued Forum Contributor kasan's Avatar
    Join Date
    07-22-2009
    Location
    Riga, Latvia
    MS-Off Ver
    Excel 2010
    Posts
    680

    Re: Check if all values in Array are greater or less than specific value in worksheet

    If all values is > A1 then value of flag will remain 0 and you will see your MsgBox, if at least one value is <= A1 then nothing will happen
    Please Login or Register  to view this content.

  8. #8
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Check if all values in Array are greater or less than specific value in worksheet

    Please Login or Register  to view this content.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  9. #9
    Forum Contributor
    Join Date
    12-22-2012
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    205

    Re: Check if all values in Array are greater or less than specific value in worksheet

    Thanks guys for input.

    Please Login or Register  to view this content.
    Didn't work, it does check the 1st value in the array and verifies >= to rad value, however because the if statement is true, the flag is set to 1 then it exits the for loop, but it only checked the 1st value in the array. I need to check that all nine values in array are >= rad value.

    Likewise for the

    Please Login or Register  to view this content.
    It looks for the min value of the array and checks if > value in "A1", again we are not looking at all 9 values in the array.

  10. #10
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Check if all values in Array are greater or less than specific value in worksheet

    If the smallest value is greater than A1, the other values must be also. There is no need to test them all.

  11. #11
    Forum Contributor
    Join Date
    12-22-2012
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    205

    Re: Check if all values in Array are greater or less than specific value in worksheet

    Oops, yes you are correct. I didn't think that through before posting my response!

    I tested the solution below and it work great, thanks for the support.

    Please Login or Register  to view this content.

  12. #12
    Forum Contributor
    Join Date
    12-22-2012
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    205

    Re: Check if all values in Array are greater or less than specific value in worksheet

    Oops, yes you are correct. I didn't think that through before posting my response!

    I tested the solution below and it work great, thanks for the support.

    Please Login or Register  to view this content.

+ 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. Replies: 3
    Last Post: 10-14-2015, 12:00 PM
  2. [SOLVED] Need to sum up to 50 values until the sum is equal to or greater than a specific value
    By TakiTaki in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-15-2015, 02:01 PM
  3. possible to check for file in multiple folders, then check for values in specific cells?
    By mattheritage in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-04-2014, 08:33 AM
  4. How to display specific cells ranges with values greater than 0 on a separate worksheet
    By studentofthegame in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-13-2012, 04:25 PM
  5. Replies: 0
    Last Post: 10-08-2012, 05:53 PM
  6. Check for values greater than zero in 2 cells
    By spartacus_33 in forum Excel General
    Replies: 4
    Last Post: 11-03-2008, 07:39 PM
  7. [SOLVED] How do I search an array for values in a column greater than zero
    By letsagmj in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 07-25-2006, 09:45 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