Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Xanadude
 
Posts: n/a
Default does the =COUNTIF have to be a range?

I need to have it look at one cell at a time, but link 20 cells in the formula.
It is supposed to count the number cells that contain an X.
I can't use the range (K6:EN6) because of a similar =COUNTIF function that
will run on the same row.

Example:
=COUNTIF((K6,R6,Y6,AF6,AT6,BA6,BH6,BO6,BV6,CC6,CJ6 ,CQ6,CX6,DE6,DL6,DS6,EG6,EN6),"X")

I get the #VALUE! error when I try this.

I tried making each cell a range (J6:K6,Q6:R6) and so on, but still get the
same error.

  #2   Report Post  
Duke Carey
 
Posts: n/a
Default

You ought to receive input from some of the sharper advisors here, but for
the meantime I'd suggest you use a custom function like the one below

Function Count_X(rng As Range, strTest As String) As Integer
Dim cc As Range
Count_X = 0
For Each cc In rng
If cc.Value = strTest Then Count_X = Count_X + 1
Next
End Function

After pasting it into a module, you'd use it by entering this formula in a
cell

=count_x((K6,R6,Y6,AF6,AT6,BA6,BH6,BO6,BV6,CC6,CJ6 ,CQ6,CX6,DE6,DL6,DS6,EG6,EN6),"X")


"Xanadude" wrote:

I need to have it look at one cell at a time, but link 20 cells in the formula.
It is supposed to count the number cells that contain an X.
I can't use the range (K6:EN6) because of a similar =COUNTIF function that
will run on the same row.

Example:
=COUNTIF((K6,R6,Y6,AF6,AT6,BA6,BH6,BO6,BV6,CC6,CJ6 ,CQ6,CX6,DE6,DL6,DS6,EG6,EN6),"X")

I get the #VALUE! error when I try this.

I tried making each cell a range (J6:K6,Q6:R6) and so on, but still get the
same error.

  #3   Report Post  
Xanadude
 
Posts: n/a
Default

How can I get the macro to run on all the worksheets? It only works on the
first one.
I get the same totals on all 17 worksheets!
I've never used one before!

"Duke Carey" wrote:

You ought to receive input from some of the sharper advisors here, but for
the meantime I'd suggest you use a custom function like the one below

Function Count_X(rng As Range, strTest As String) As Integer
Dim cc As Range
Count_X = 0
For Each cc In rng
If cc.Value = strTest Then Count_X = Count_X + 1
Next
End Function

After pasting it into a module, you'd use it by entering this formula in a
cell

=count_x((K6,R6,Y6,AF6,AT6,BA6,BH6,BO6,BV6,CC6,CJ6 ,CQ6,CX6,DE6,DL6,DS6,EG6,EN6),"X")


"Xanadude" wrote:

I need to have it look at one cell at a time, but link 20 cells in the formula.
It is supposed to count the number cells that contain an X.
I can't use the range (K6:EN6) because of a similar =COUNTIF function that
will run on the same row.

Example:
=COUNTIF((K6,R6,Y6,AF6,AT6,BA6,BH6,BO6,BV6,CC6,CJ6 ,CQ6,CX6,DE6,DL6,DS6,EG6,EN6),"X")

I get the #VALUE! error when I try this.

I tried making each cell a range (J6:K6,Q6:R6) and so on, but still get the
same error.

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
Counting empty cells within a range of cells Rosehill - ExcelForums.com New Users to Excel 2 May 2nd 05 08:53 AM
Can a formula check for a certain value in a range? Lee IT Excel Discussion (Misc queries) 3 April 8th 05 07:36 AM
can a formula check for a certain value in a range? Lee IT Excel Discussion (Misc queries) 1 April 7th 05 04:31 PM
Define a range based on another named range Basil Excel Worksheet Functions 2 February 21st 05 01:47 PM
named range refers to: in a chart Spencer Hutton Excel Discussion (Misc queries) 1 December 14th 04 10:15 PM


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