Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 28
Default Stopping a CountIf

In a column I need to count how many rows from the start of the column are
greater then zero. The trick is once the value is a 0 or a negative, it is to
stop counting.

Maximum number is 121.

I have a macro that does this but am looking for a way to do this through a
formula.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15,768
Default Stopping a CountIf

If I understand what you're wanting to do, try this...

Assuming the data is in a contiguous block (no empty/blank cells within the
range)

Array entered** :

=IF(COUNTIF(A2:A200,"<=0"),MATCH(TRUE,A2:A200<=0,0 )-1,"")

** array formulas need to be entered using the key combination of
CTRL,SHIFT,ENTER (not just ENTER). Hold down both the CTRL key and the SHIFT
key then hit ENTER.

--
Biff
Microsoft Excel MVP


"Don Kline" wrote in message
...
In a column I need to count how many rows from the start of the column are
greater then zero. The trick is once the value is a 0 or a negative, it is
to
stop counting.

Maximum number is 121.

I have a macro that does this but am looking for a way to do this through
a
formula.



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 793
Default Stopping a CountIf

With your numbers in Col A, try this in B1
=MIN(IF(A1:A21<=0,ROW(A1:A20),""))
adjust 21 to your last row and press CTRL-SHIFT-ENTER after typing/pasting
the formula as it is an array formula

"Don Kline" wrote:

In a column I need to count how many rows from the start of the column are
greater then zero. The trick is once the value is a 0 or a negative, it is to
stop counting.

Maximum number is 121.

I have a macro that does this but am looking for a way to do this through a
formula.

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 28
Default Stopping a CountIf

Thanks for the solution. It solves my problem via a formula and I can ditch
the macro.

"T. Valko" wrote:

If I understand what you're wanting to do, try this...

Assuming the data is in a contiguous block (no empty/blank cells within the
range)

Array entered** :

=IF(COUNTIF(A2:A200,"<=0"),MATCH(TRUE,A2:A200<=0,0 )-1,"")

** array formulas need to be entered using the key combination of
CTRL,SHIFT,ENTER (not just ENTER). Hold down both the CTRL key and the SHIFT
key then hit ENTER.

--
Biff
Microsoft Excel MVP


"Don Kline" wrote in message
...
In a column I need to count how many rows from the start of the column are
greater then zero. The trick is once the value is a 0 or a negative, it is
to
stop counting.

Maximum number is 121.

I have a macro that does this but am looking for a way to do this through
a
formula.




  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 28
Default Stopping a CountIf

It returned a 3 when I was expecting 20. I'll play with it some more. Thanks
for the reply.

"Sheeloo" wrote:

With your numbers in Col A, try this in B1
=MIN(IF(A1:A21<=0,ROW(A1:A20),""))
adjust 21 to your last row and press CTRL-SHIFT-ENTER after typing/pasting
the formula as it is an array formula

"Don Kline" wrote:

In a column I need to count how many rows from the start of the column are
greater then zero. The trick is once the value is a 0 or a negative, it is to
stop counting.

Maximum number is 121.

I have a macro that does this but am looking for a way to do this through a
formula.



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15,768
Default Stopping a CountIf

You're welcome. Thanks for the feedback!

--
Biff
Microsoft Excel MVP


"Don Kline" wrote in message
...
Thanks for the solution. It solves my problem via a formula and I can
ditch
the macro.

"T. Valko" wrote:

If I understand what you're wanting to do, try this...

Assuming the data is in a contiguous block (no empty/blank cells within
the
range)

Array entered** :

=IF(COUNTIF(A2:A200,"<=0"),MATCH(TRUE,A2:A200<=0,0 )-1,"")

** array formulas need to be entered using the key combination of
CTRL,SHIFT,ENTER (not just ENTER). Hold down both the CTRL key and the
SHIFT
key then hit ENTER.

--
Biff
Microsoft Excel MVP


"Don Kline" wrote in message
...
In a column I need to count how many rows from the start of the column
are
greater then zero. The trick is once the value is a 0 or a negative, it
is
to
stop counting.

Maximum number is 121.

I have a macro that does this but am looking for a way to do this
through
a
formula.






Reply
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
Stopping a userform subroutine teepee[_3_] Excel Discussion (Misc queries) 5 January 13th 09 01:10 AM
stopping code Jase Excel Discussion (Misc queries) 1 October 6th 08 05:42 PM
Stopping a formula Roachy Excel Discussion (Misc queries) 3 July 1st 08 03:31 PM
Stopping Calculation Kelly Excel Discussion (Misc queries) 2 March 15th 06 10:56 PM
Stopping A Sheet From Scrolling mully New Users to Excel 5 June 9th 05 03:38 PM


All times are GMT +1. The time now is 01:55 PM.

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

About Us

"It's about Microsoft Excel"