+ Reply to Thread
Results 1 to 9 of 9

Finding Negative Numbers

  1. #1
    Registered User
    Join Date
    05-16-2017
    Location
    Ankara,Turkey
    MS-Off Ver
    2016
    Posts
    20

    Finding Negative Numbers

    I have this sheet.

    If there is/are negative number(s) between DATA cells written A Column, I want spot them writting YES or NO

    As seen at the example:

    - There is no negative number between A1:A3 so when DATA is written NO must be written just next cell (B3)

    - There is no negative number between A3:A13, the result is same

    - There is one negative number (A20) between A13:A26, YES is written next cell (B26)

    I can arrange A column. The question is this:

    What kind of function must be written at the B Column that;

    When does Excel spot the "DATA", Excel must search the field between the last two DATA cells and if there is negative number or not, YES or NO must be written in the cell just next the last DATA cell ?

    Thanks a lot for help.

    DATA.jpeg
    Last edited by excelman13; 09-30-2018 at 02:52 PM.

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Finding Negative Numbers

    Try this user defined function

    Please Login or Register  to view this content.
    Open the VBA editor by hitting Alt F11.
    Insert a new module with Insert - Module
    Paste in the above function
    Go back to the sheet by hitting Alt F11.

    In a B1, enter =SpotNegativeNumbers(B1) and copy down

    Remember to save the workbook as a macro enabled workbook .xlsm
    Martin

  3. #3
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Finding Negative Numbers

    User defined functions should be avoided when the task can be achieved efficiently with native functions.

    In B2 and fill down

    =IF(A2="Data",IF(MIN(INDEX(B$1:B1,IFERROR(MATCH("Data",B$1:B1,0),1)):B1)<0,"Yes","No"),"")

  4. #4
    Registered User
    Join Date
    05-16-2017
    Location
    Ankara,Turkey
    MS-Off Ver
    2016
    Posts
    20

    Re: Finding Negative Numbers

    mrice, Thank you for reply, it solved my problem.

    joson.b75

    =IF(A2="Data",IF(MIN(INDEX(B$1:B1,IFERROR(MATCH("Data",B$1:B1,0),1)):B1)<0,"Yes","No"),"")

    with this solution I got this picture and it didn't detect the negative numbers. The picture is this:



    DATA1.jpeg

  5. #5
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Finding Negative Numbers

    Sorry, I just typed the formula in my reply and missed an error in the ranges, the formula should be looking at column A, not column B.

    In B2 and filled down

    =IF(A2="Data",IF(MIN(INDEX(A$1:A1,IFERROR(MATCH("Data",A$1:A1,0),1)):A1)<0,"Yes","No"),"")

  6. #6
    Registered User
    Join Date
    05-16-2017
    Location
    Ankara,Turkey
    MS-Off Ver
    2016
    Posts
    20

    Re: Finding Negative Numbers

    I think I make a mistake some where. But my result is this:

    DATA3.jpeg

    There must be NO next to the second DATA but no NO

  7. #7
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,908

    Re: Finding Negative Numbers

    Try:

    =IF(A2="Data",IF(MIN(INDEX(A$1:A1,IFERROR(-LOOKUP(1,-ROW(A$1:A1)/(A$1:A1="DATA")),1)):A1)<0,"Yes","No"),"")
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Finding Negative Numbers

    Have you changed the formula to match the ranges used in your data? It looks like you might have done it incorrectly.

    I can't tell you what you have done wrong because I can't see the edited formula or the actual ranges used from your screen capture.

  9. #9
    Registered User
    Join Date
    05-16-2017
    Location
    Ankara,Turkey
    MS-Off Ver
    2016
    Posts
    20

    Re: Finding Negative Numbers

    It is OK now.
    That is a kind of FOREX early warning sheet that will help too much.
    Thanks a lot.



    DATA4.jpeg

+ 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: 10
    Last Post: 09-24-2018, 09:26 AM
  2. Replies: 9
    Last Post: 04-20-2016, 02:42 AM
  3. [SOLVED] Finding average value for the positive and negative set of numbers
    By thilag in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-26-2014, 04:39 AM
  4. [SOLVED] Need help with finding first negative value in a list of numbers
    By Good 4 Me in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-30-2014, 08:31 PM
  5. [SOLVED] SUMIF positive and negative numbers - take double a negative number?
    By Zordrail in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-16-2014, 08:34 AM
  6. Replies: 1
    Last Post: 11-20-2008, 01:52 AM
  7. finding out pairs of positive & negative numbers!
    By via135 in forum Excel General
    Replies: 11
    Last Post: 12-18-2005, 02:27 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