Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default Count non-zero cells

Excel XP & Win XP
I have a sheet with zero values suppressed (Tools - Options - View tab -
Uncheck Zero values).
I have a range, say F13:F16.
Each cell has a formula that produces a number.
The result in one cell is zero so that cell appears blank.
I want to count the number of non-zero cells in the range.
The worksheet formula:
CountIf(F13:F16,"<0")
produces the correct answer, 3.
I need to do this in VBA so I use:
Range("H7").Value = Application.CountIf(Range("F13:F17"), "<0")
This produces a 4.
What is the correct syntax to produce a 3?
Thanks for your time. Otto



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Count non-zero cells

You have different ranges in your formula (F13:F16) & (F13:F17)

using the same range in both I get the same answer.

Mike

"Otto Moehrbach" wrote:

Excel XP & Win XP
I have a sheet with zero values suppressed (Tools - Options - View tab -
Uncheck Zero values).
I have a range, say F13:F16.
Each cell has a formula that produces a number.
The result in one cell is zero so that cell appears blank.
I want to count the number of non-zero cells in the range.
The worksheet formula:
CountIf(F13:F16,"<0")
produces the correct answer, 3.
I need to do this in VBA so I use:
Range("H7").Value = Application.CountIf(Range("F13:F17"), "<0")
This produces a 4.
What is the correct syntax to produce a 3?
Thanks for your time. Otto




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,886
Default Count non-zero cells

Hi Otto

Unless it was a typo when posting, you are looking at 2 different size
ranges
F13:F16 with formula
F13:F17 in code
This may well account for the different result.
--
Regards

Roger Govier


"Otto Moehrbach" wrote in message
...
Excel XP & Win XP
I have a sheet with zero values suppressed (Tools - Options - View
tab - Uncheck Zero values).
I have a range, say F13:F16.
Each cell has a formula that produces a number.
The result in one cell is zero so that cell appears blank.
I want to count the number of non-zero cells in the range.
The worksheet formula:
CountIf(F13:F16,"<0")
produces the correct answer, 3.
I need to do this in VBA so I use:
Range("H7").Value = Application.CountIf(Range("F13:F17"), "<0")
This produces a 4.
What is the correct syntax to produce a 3?
Thanks for your time. Otto





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default Count non-zero cells

Mike, Roger
You're absolutely right. A typo. Thanks. Otto
"Otto Moehrbach" wrote in message
...
Excel XP & Win XP
I have a sheet with zero values suppressed (Tools - Options - View tab -
Uncheck Zero values).
I have a range, say F13:F16.
Each cell has a formula that produces a number.
The result in one cell is zero so that cell appears blank.
I want to count the number of non-zero cells in the range.
The worksheet formula:
CountIf(F13:F16,"<0")
produces the correct answer, 3.
I need to do this in VBA so I use:
Range("H7").Value = Application.CountIf(Range("F13:F17"), "<0")
This produces a 4.
What is the correct syntax to produce a 3?
Thanks for your time. Otto





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
how to count#cells w/= value in other column and not count blank c aganoe Excel Worksheet Functions 4 April 9th 10 11:36 AM
count cells, then reset count when value in another cell changes Mitchell_Collen via OfficeKB.com Excel Worksheet Functions 4 February 20th 09 04:22 AM
How do I count cells with text but ignore cells with spaces? Husker87 Excel Discussion (Misc queries) 2 September 21st 06 12:31 AM
Count Empty Cells in Range After Cells with Data David Excel Programming 16 September 17th 06 03:03 PM
Using the COUNT funciton to count cells with values wjsubs[_5_] Excel Programming 4 July 9th 04 05:00 PM


All times are GMT +1. The time now is 05:22 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"