Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 829
Default countif

"fzl2007" wrote:
I want to count the rows if the value of the column,
from bottom up, changes sign

[....]
For example,
-2.1 31.2 -2.1
0.3 44.8 1.6
-1.1 -9.4 5.3
44 10.4 9
13.1 -2.2 0
12.2 -11.1 3.2
counter=3 counter=2 counter=1


For the data in A1:A6, enter the following __array_formula__ (press
ctrl+shift+Enter instead of Enter):

=6-MATCH(2,1/(SIGN(A6)<SIGN(A1:A5)))

6 can be replaced by COUNT(A1:A6).

MATCH returns the last row number relative to A1 whose sign differs from A6.
6-MATCH(...) makes that row number relative to A6.

Caveat: This returns a #N/A if there is no sign change. If you do not like
that, you can do the following in XL2007 and later:

=IFERROR(6-MATCH(2,1/(SIGN(A6)<SIGN(A1:A5))),"")

In XL2003 and earlier:

=IF(SUMPRODUCT(--(SIGN(A6)<SIGN(A1:A5)))0,
6-MATCH(2,1/(SIGN(A6)<SIGN(A1:A5))),"")

Both alternatives are also __array_formulas__ (press ctrl+shift+Enter
instead of Enter).

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
COUNTIF Mac Excel Discussion (Misc queries) 6 December 4th 07 04:08 PM
How do I use a countif function according to two other countif fu. Kirsty Excel Worksheet Functions 2 February 20th 06 11:44 AM
edit this =COUNTIF(A1:F16,"*1-2*")+COUNTIF(A1:F16,"*2-1*") sctroy Excel Discussion (Misc queries) 2 September 25th 05 04:13 AM
COUNTIF or not to COUNTIF on a range in another sheet Ellie Excel Worksheet Functions 4 September 15th 05 10:06 PM
COUNTIF in one colum then COUNTIF in another...??? JonnieP Excel Worksheet Functions 3 February 22nd 05 02:55 PM


All times are GMT +1. The time now is 10:23 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"