+ Reply to Thread
Results 1 to 19 of 19

Count 0 and negitive numbers since last positive number from right to left

  1. #1
    Registered User
    Join Date
    04-07-2014
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2003
    Posts
    42

    Count 0 and negitive numbers since last positive number from right to left

    Hi Guys,

    I have attached an example. Basically I had this set up to calculate the row and give the answer at the end. But now I cant see the results without scrolling, so I want to move the answer fields to the C column and add new data into the D column while keeping all the data in the formula.

    I hopr you can understand what I'm trying to say.

    Thanks in advance,


    Green

  2. #2
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Count 0 and negitive numbers since last positive number from right to left

    How about in C2:
    =MATCH(TRUE,INDEX($D2:$I2>0,),0)-1
    Quang PT

  3. #3
    Registered User
    Join Date
    04-07-2014
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2003
    Posts
    42

    Re: Count 0 and negitive numbers since last positive number from right to left

    That works for all C cells when I remove the, $, but if the row contains all "0" i get a N/A error.

    Edit: Also it doesn't recognise negitive numbers.
    Last edited by gogreenpower; 04-29-2014 at 02:09 AM.

  4. #4
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Count 0 and negitive numbers since last positive number from right to left

    Hi,

    Since your numbers are only ever -1, 0 or 1:

    =MATCH(1,D2:I2,0)-1

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  5. #5
    Registered User
    Join Date
    04-07-2014
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2003
    Posts
    42

    Re: Count 0 and negitive numbers since last positive number from right to left

    Sorry the numbers in the real one are percentages, ranging from -100.00% to 500.00%. I just used those numbers for simplicity. Is there a way to get the formula to expand when I add a new data column in column D pushing the older ones to the right?

    Thanks

  6. #6
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Count 0 and negitive numbers since last positive number from right to left

    In that case could you re-post your workbook with some relevant data and indicate clearly your expected results?

    Regards

  7. #7
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Count 0 and negitive numbers since last positive number from right to left


  8. #8
    Registered User
    Join Date
    04-07-2014
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2003
    Posts
    42

    Re: Count 0 and negitive numbers since last positive number from right to left

    When I entered new figures I get the #name? error. I have updated the workbook with real world data to help.


    Quote Originally Posted by kvsrinivasamurthy View Post
    Pl see attached file.
    Last edited by gogreenpower; 05-01-2014 at 02:59 AM. Reason: Workbook corrected

  9. #9
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Count 0 and negitive numbers since last positive number from right to left

    Hi,

    Why do you say the answer for row 3 should be 4?

    Regards

  10. #10
    Registered User
    Join Date
    04-07-2014
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2003
    Posts
    42

    Re: Count 0 and negitive numbers since last positive number from right to left

    I have figured out that this is an Excel 2007 formula, can anyone rewite this to work with the 2003 version?

    =_xlfn.IFERROR(SMALL(IF($D4:$I4>0,COLUMN($D4:$I4)-4,""),1),"")

  11. #11
    Registered User
    Join Date
    04-07-2014
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2003
    Posts
    42

    Re: Count 0 and negitive numbers since last positive number from right to left

    Sorry, I missed it, you are correct, it should be 3.

    Quote Originally Posted by XOR LX View Post
    Hi,

    Why do you say the answer for row 3 should be 4?

    Regards

  12. #12
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Count 0 and negitive numbers since last positive number from right to left

    Try:

    =MATCH(TRUE,INDEX(D2:I2>0,,),0)-1

    Regards

    Edit: Just realised that's exactly what Bebo gave way back in post #2!
    Last edited by XOR LX; 05-01-2014 at 03:14 AM.

  13. #13
    Registered User
    Join Date
    04-07-2014
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2003
    Posts
    42

    Re: Count 0 and negitive numbers since last positive number from right to left

    This works with every combination except if the row contains all 0 entries, it returns #N/A

    Quote Originally Posted by XOR LX View Post
    Try:

    =MATCH(TRUE,INDEX(D2:I2>0,,),0)-1

    Regards

    Edit: Just realised that's exactly what Bebo gave way back in post #2!

  14. #14
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Count 0 and negitive numbers since last positive number from right to left

    Well, what do you want it to return in those cases? There is no "last positive number".

    Regards

  15. #15
    Registered User
    Join Date
    04-07-2014
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2003
    Posts
    42

    Re: Count 0 and negitive numbers since last positive number from right to left

    The total number of cells?. I have updated the workbook to show you. Also is there a way to get the formula to expand if I add a new data coloumn into 'Column D'?


    Thanks for the help so far.

  16. #16
    Valued Forum Contributor Saarang84's Avatar
    Join Date
    02-19-2009
    Location
    Chennai, India
    MS-Off Ver
    XL 2003 to 2010
    Posts
    812

    Re: Count 0 and negitive numbers since last positive number from right to left

    Hi Green,

    For Excel 2003 version, use the below formulas :

    Srinivas Murthy's solution :

    Please Login or Register  to view this content.
    You need to confirm that array formula is used by pressing CTRL + SHIFT + ENTER.

    For Bebo / XOR LX solution :

    Please Login or Register  to view this content.
    If my assistance has helped, there is a reputation icon * on the left hand corner below the post - you can show your appreciation to the user who has helped in resolving your requirement.

    If your requirement has been solved please mark your thread as Solved.
    In the menu bar above the very first post, select Thread Tools, then select "Mark this thread as Solved".

    Kindly use [FORMULA] or [CODE] tags when posting your code.

    Regards,
    Sarang

  17. #17
    Registered User
    Join Date
    04-07-2014
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2003
    Posts
    42

    Re: Count 0 and negitive numbers since last positive number from right to left

    I have them both setup and working with the exception of this last question. Its in red on the workbooks, one for each formula incase one is easier than the other.

    Thanks
    Attached Files Attached Files
    Last edited by gogreenpower; 05-01-2014 at 04:41 AM.

  18. #18
    Valued Forum Contributor Saarang84's Avatar
    Join Date
    02-19-2009
    Location
    Chennai, India
    MS-Off Ver
    XL 2003 to 2010
    Posts
    812

    Re: Count 0 and negitive numbers since last positive number from right to left

    Hi Green,

    You already have the correct solution.. Its just a question of how it is being used.

    You just need to insert a new column in between in your range (with %'s) after col D (or after the first column with %'s whatever), and need to paste the values of the first column with %'s into the newly created column and then overwrite the first column with new date & % values.

    There is no need for any corrections with the below given solution.
    Last edited by Saarang84; 05-01-2014 at 07:25 AM.

  19. #19
    Registered User
    Join Date
    04-07-2014
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2003
    Posts
    42

    Re: Count 0 and negitive numbers since last positive number from right to left

    Hi Saarang,

    Thanks for your help, your description is what I plan on doing, I just wondered if there was some type of dynamic formula that would save me the hassle. But that's ok, thank you for all your help. Much appreciated.

    Regards,


    Green

+ 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. Count only if negitive and only if positive.
    By gibbsmachine in forum Excel General
    Replies: 3
    Last Post: 12-21-2011, 09:27 AM
  2. Replies: 5
    Last Post: 09-01-2011, 03:46 AM
  3. How do I change numbers from positive to negitive
    By Debi in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-11-2005, 01:09 PM
  4. [SOLVED] negitive and positive numbers
    By kematz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-02-2005, 07:06 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