Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / June 2007

Tip: Looking for answers? Try searching our database.

Using COUNTIF

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jack - 20 Jun 2007 04:54 GMT
I have a range of number between 1 and 5.  Four of the cells in the range
display formulas.  The formulas I am using to determine the number of 1's,
2's, 3's, etc  are: COUNTIF(A1:A233,"1");..... COUNTIF(A1:A233,"5").   How do
I get the COUNTIF formulas to count the cells containing the formulas?
Teethless mama - 20 Jun 2007 05:11 GMT
=SUMPRODUCT(--(A1:A233>=1),--(A1:A233<=5))
or
=SUM(COUNTIF(A1:A233,{1,2,3,4,5}))

> I have a range of number between 1 and 5.  Four of the cells in the range
> display formulas.  The formulas I am using to determine the number of 1's,
> 2's, 3's, etc  are: COUNTIF(A1:A233,"1");..... COUNTIF(A1:A233,"5").   How do
> I get the COUNTIF formulas to count the cells containing the formulas?
Bob Phillips - 20 Jun 2007 09:17 GMT
You need a UDF to return an array of TRUE/FALSE for formulae

Function IsFormula(rng As Range)
Dim cell As Range, row As Range
Dim i As Long, j As Long
Dim aryFormulae As Variant

   If rng.Areas.Count > 1 Then
       IsFormula = CVErr(xlErrValue)
       Exit Function
   End If

   If rng.Cells.Count = 1 Then

       ReDim aryFormulae(1 To 1)
       aryFormulae(1) = rng.HasFormula
   Else

       aryFormulae = rng.Value
       i = 0

       For Each row In rng.Rows
           i = i + 1
           j = 0

           For Each cell In row.Cells
               j = j + 1
               aryFormulae(i, j) = cell.HasFormula
           Next cell
       Next row
   End If

   IsFormula = aryFormulae
End Function

and then count them like so

=SUMPRODUCT(--(IsFormula(A1:A10)))

Signature

HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

>I have a range of number between 1 and 5.  Four of the cells in the range
> display formulas.  The formulas I am using to determine the number of 1's,
> 2's, 3's, etc  are: COUNTIF(A1:A233,"1");..... COUNTIF(A1:A233,"5").   How
> do
> I get the COUNTIF formulas to count the cells containing the formulas?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.