+ Reply to Thread
Results 1 to 7 of 7

How to Identify If an Array have blank or -ve values

  1. #1
    Registered User
    Join Date
    10-23-2012
    Location
    LON
    MS-Off Ver
    Excel 2003
    Posts
    29

    Unhappy How to Identify If an Array have blank or -ve values

    Please see the code below :

    Please Login or Register  to view this content.
    I have a situation where later in the code I have to check if the negVal Array has Blank or -ve values
    If negVal has -ve value(s) then find the max negative value, If it has only one -ve val then return that value
    If nevVal has no negative Val or 0 blank then only go check posVal Array and find max +Val

    Regards
    Last edited by mandukes; 05-20-2013 at 02:16 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,418

    Re: How to Identify If an Array have blank or -ve values

    Why not a) count the positive and negative numbers as you store them and b) store and track the greatest positive number and the greatest negative number as you go along?

    You've already checked if the number is negative or positive so add counters and storage variables.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Valued Forum Contributor
    Join Date
    03-21-2013
    Location
    cyberia
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: How to Identify If an Array have blank or -ve values

    I don't clearly see your problem.

    Your code seems to define elements of nagVal (earlier declared as negVal) as negative values of A.

    Are you wanting to check if negVal(?) has any negative elements instead of being entirely empty?

    If so, does your "Max" of a negative number mean closer to zero or further from zero (i.e. max in the negative direction)? And, if such value exists, what do you want done with it?

  4. #4
    Registered User
    Join Date
    10-23-2012
    Location
    LON
    MS-Off Ver
    Excel 2003
    Posts
    29

    Re: How to Identify If an Array have blank or -ve values

    Quote Originally Posted by kalak View Post
    I don't clearly see your problem.

    Your code seems to define elements of nagVal (earlier declared as negVal) as negative values of A.

    Are you wanting to check if negVal(?) has any negative elements instead of being entirely empty?

    If so, does your "Max" of a negative number mean closer to zero or further from zero (i.e. max in the negative direction)? And, if such value exists, what do you want done with it?
    1. Your code seems to define elements of nagVal (earlier declared as negVal) as negative values of A
    Ans. It was a typing mistake .
    2. Are you wanting to check if negVal(?) has negative elements
    Ans. YES
    3.If so, does your "Max" of a negative number mean closer to zero or further from zero (i.e. max in the negative direction)?
    Ans. further from zero
    Getting max value is not a big deal.I can get it through
    MaxNeg = Excel.workbookfunction.Min(negVal)
    Last edited by mandukes; 05-20-2013 at 02:30 PM.

  5. #5
    Registered User
    Join Date
    10-23-2012
    Location
    LON
    MS-Off Ver
    Excel 2003
    Posts
    29

    Re: How to Identify If an Array have blank or -ve values

    Quote Originally Posted by TMShucks View Post
    Why not a) count the positive and negative numbers as you store them and b) store and track the greatest positive number and the greatest negative number as you go along?

    You've already checked if the number is negative or positive so add counters and storage variables.

    Regards, TMS
    It's a good suggestion but I don't want to do it that way!

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,418

    Re: How to Identify If an Array have blank or -ve values

    Fair enough.

    Regards, TMS

  7. #7
    Valued Forum Contributor
    Join Date
    03-21-2013
    Location
    cyberia
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: How to Identify If an Array have blank or -ve values

    Quote Originally Posted by mandukes View Post
    1. Your code seems to define elements of nagVal (earlier declared as negVal) as negative values of A
    Ans. It was a typing mistake .
    2. Are you wanting to check if negVal(?) has negative elements
    Ans. YES
    3.If so, does your "Max" of a negative number mean closer to zero or further from zero (i.e. max in the negative direction)?
    Ans. further from zero
    Getting max value is not a big deal.I can get it through
    MaxNeg = Excel.workbookfunction.Min(negVal)
    Here's a modification of your code. You can look at this (run it on a blank worksheet, it generates its own test data) and see if you find anything useful from it.
    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)

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