+ Reply to Thread
Results 1 to 7 of 7

Find pattern (positive, negative, positive)

  1. #1
    Forum Contributor
    Join Date
    10-26-2013
    Location
    Athens, Greece
    MS-Off Ver
    Excel 2013
    Posts
    248

    Find pattern (positive, negative, positive)

    Hi. I'm attaching my workbook. I have a column that has numbers. (The first number will always be positive). I would like to get a "flag" (1 in another column) whenever the data goes from positive to negative and then positive again (no need for back to back to back). If I get a 1 it should stop looking at this pattern and look to find the next negative and get a 2 then. When that happens start finding for the 1 again (the first pattern). Here is an example to understand.

    Column A Column B
    3.86%
    3.79%
    -2.88%
    -2.33%
    3.36% 1
    2.07%
    4.65%
    -3.87% 2
    3.88%
    -3.32%
    8.20% 1
    -0.46% 2
    1.49%
    2.62%
    So, at B5 I get 1 because we have a positive first (A1) then at A3 a negative and then at A5 a positive. Now that it got the 1 it will look for the first negative which it gets at A8.
    After that, it tries to find the 1 again. A9 is positive, A10 is negative and A11 is positive so B11 will be 1. A12 is negative so B12 will be 2.
    I don't have a specific preference for a formula or a macro.

    Hope you understand what I'm trying to do!
    Thanks for any help!

    P.S. I have asked the same question in another forum http://www.mrexcel.com/forum/excel-q...ml#post4535573
    Attached Files Attached Files
    Last edited by tsakta13ole; 05-28-2016 at 01:25 PM.

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Find pattern (positive, negative, positive)

    I'm going to see if I can get what you want. B5 = 1 because the trend went from positive to negative to positive. B8 = 2 because it went from positive to negative. B11 = 1 because it went from positive to negative to positive, and B12 = 2 because it went from positive to negative.

    So, a positive to negative to positive =1 first flip back to negative = 2.

    Do I have that right?
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Forum Contributor
    Join Date
    10-26-2013
    Location
    Athens, Greece
    MS-Off Ver
    Excel 2013
    Posts
    248

    Re: Find pattern (positive, negative, positive)

    Thank you for your answer!

    Yes correct! For 1, the trend to be positive, negative, positive (just the trend- no need for consecutive positive, negative, positive) and for 2 first flip back to negative, correct.

    Thank you!

  4. #4
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Find pattern (positive, negative, positive)

    There are errors in your data
    B9 should be 1 since A7 is positive, A8 is negative and A9 is back to positive again.
    B13 should also be 1 for the same reason since A11 (+) A12 (-) A3 (+)
    B16 should be 2 since A14 (-) A15 (+) A16 (-)
    B23 should be 1 since A21 (+) A22 (-) A23 (+)
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  5. #5
    Forum Contributor
    Join Date
    10-26-2013
    Location
    Athens, Greece
    MS-Off Ver
    Excel 2013
    Posts
    248

    Re: Find pattern (positive, negative, positive)

    Thank you for your answer Special-K!

    Well, when 2 occurred I was looking to "restart" the process that's why the data in column B was like that. But if you can do it with your thinking and results in column B I have no problem!

    Thanks again!

  6. #6
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Find pattern (positive, negative, positive)

    Unfortunately I discovered this manually, and at present don't have a formula to solve this

  7. #7
    Forum Contributor
    Join Date
    10-26-2013
    Location
    Athens, Greece
    MS-Off Ver
    Excel 2013
    Posts
    248

    Re: Find pattern (positive, negative, positive)

    This formula found on the other forum helped me solve the problem
    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. Formula to get negative to positive value and positive to zero
    By Nikunj Morjaria in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-18-2014, 08:27 AM
  2. Loop through rows identifying a positive/negative pattern and return value
    By nguyeda in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-21-2013, 04:15 PM
  3. Positive to a Positive and Negative to a Positve
    By alorenzini in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-16-2011, 11:47 AM
  4. Convert negative to positive in sheet containing both positive/negative numbers
    By sa02000 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-29-2010, 07:52 PM
  5. Replies: 1
    Last Post: 08-14-2009, 11:17 AM
  6. adding positive and negative numbers all as positive
    By tomvh444 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-18-2009, 04:08 PM
  7. Replies: 2
    Last Post: 11-13-2008, 12:35 AM

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