+ Reply to Thread
Results 1 to 10 of 10

CountA - stop counting in column when number changes positive or negative

  1. #1
    Registered User
    Join Date
    04-21-2016
    Location
    London, UK
    MS-Off Ver
    2013
    Posts
    9

    CountA - stop counting in column when number changes positive or negative

    Hello..... I can't figure this out. I have some columns of numbers which vary between positive and negative. Starting at the top of each column, I want to count down the number of cells (that are either positive or negative) and when the value in a cell changes sign, I want the count to stop and return how many cells the count got up to before being stopped. Hopefully this expalins... http://my.jetscreenshot.com/16785/20160425-zwrv-92kb
    Many thanks

    I probably should have posted this in the Formulas and Functions forum.......
    Last edited by Hallgente; 04-25-2016 at 04:09 PM.

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: CountA - stop counting in column when number changes positive or negative

    Where would you the result to be display
    How many columns to treat
    It will be easier to attach an excel file to prepare the macro
    - Battle without fear gives no glory - Just try

  3. #3
    Registered User
    Join Date
    04-21-2016
    Location
    London, UK
    MS-Off Ver
    2013
    Posts
    9

    Re: CountA - stop counting in column when number changes positive or negative

    Hi PCI - I was hoping to do the count with a formula becuase I have multiple workbooks in a library and each workbook (at the moment) has 30 sheets in it. The result of the column count would be in each sheet copied to a summary sheet for each workbook. At the moment I have a Macro for each sheet that collects data from Yahoo and have to click on each sheet to run the macro (therefore doing so 30 times per work book each day - yawn) I was hoping not to add to this arduous task with another macro. What do you think... is it possible to do with a formula?
    Many thanks for the quick response by the way...

  4. #4
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: CountA - stop counting in column when number changes positive or negative

    Try this UDF
    Somewhere put =Treat(B1:B18), where B1:B18 is the range to treat
    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: CountA - stop counting in column when number changes positive or negative

    A remake to care when the range has only one cell
    Please Login or Register  to view this content.

  6. #6
    Valued Forum Contributor loginjmor's Avatar
    Join Date
    01-31-2013
    Location
    Cedar Rapids, Iowa
    MS-Off Ver
    Excel 2013
    Posts
    1,073

    Re: CountA - stop counting in column when number changes positive or negative

    Hi -

    If you want to do this as a formula, try this:

    {=IF(A1>0,SMALL(IF(SIGN($A$1:$A$23)<0,ROW($A$1:$A$23)),1),SMALL(IF(SIGN($A$1:$A$23)>0,ROW(A1:$A$23)),1))-ROW($A$1)}

    This is an Array formula, so copy everything inside the curly braces {} but not the curly braces, and paste the formula into your worksheet where you want the answer to appear. Click in the formula edit window and press Ctrl-Shift-Enter at the same time so Excel makes this an array formula. Excel will add the curly braces.

    Please note this formula is looking at a data set in the range of A1:A23. So you will have to edit the ranges to fit your data. The ROW function returns the row of the first time the data set changes sign. So you have to subtract the row number of the first value (the ROW function at the very end of the formula) to get the correct number.

    Hope this helps.
    ____________________________________________
    If this has solved your problem, please edit the thread title to add the word [SOLVED] at the beginning. You can do this by
    -Go to the top of the first post
    -Select Thread Tools
    -Select Mark thread as Solved

    If I have been particularly helpful, please "bump" my reputation by pressing the small star in the lower left corner of my post.

  7. #7
    Registered User
    Join Date
    04-21-2016
    Location
    London, UK
    MS-Off Ver
    2013
    Posts
    9

    Re: CountA - stop counting in column when number changes positive or negative

    Many thanks loginjmor

  8. #8
    Valued Forum Contributor loginjmor's Avatar
    Join Date
    01-31-2013
    Location
    Cedar Rapids, Iowa
    MS-Off Ver
    Excel 2013
    Posts
    1,073

    Re: CountA - stop counting in column when number changes positive or negative

    No problem! Thanks for the bump! If you are satisfied with this answer, please edit the thread title to add the word SOLVED.

  9. #9
    Registered User
    Join Date
    04-21-2016
    Location
    London, UK
    MS-Off Ver
    2013
    Posts
    9

    Re: CountA - stop counting in column when number changes positive or negative - SOLVED

    There you go. Many thanks to PCI and loginjmor

  10. #10
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: CountA - stop counting in column when number changes positive or negative

    You are welcome,
    Now I'm not sure that a formula is the best idea to save you time (effort).
    I believe a macro collecting the data from all files and all sheets (as you need to do it with formulas) will be more useful
    PCI

+ 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: 1
    Last Post: 04-14-2015, 08:34 PM
  2. Counting number of users with positive/negative outcomes
    By iainwall in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-09-2014, 05:24 PM
  3. Carrying Over Negative number to next column as a positive number
    By Redraven in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-21-2014, 06:39 AM
  4. [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
  5. Replies: 1
    Last Post: 11-20-2008, 01:52 AM
  6. Replies: 2
    Last Post: 11-13-2008, 12:35 AM
  7. counting a string of negative or positive numbers
    By mcarrington in forum Excel General
    Replies: 0
    Last Post: 01-12-2006, 07:02 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