Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Countif using the same cell on every sheet


Is it possible to do a countif using the same cell reference for every
worksheet?

Like a shorthand of doing but i would also like to covert it to VB
code
=COUNTIF('AU05-02'!D16,"X")+COUNTIF('AU05-09'!D16,"X")+COUNTIF('AU05-12'!D16,"X")+COUNTIF('AU05-14'!D16,"X")+COUNTIF('AU05-23'!D16,"X")+COUNTIF('AU04-24'!D16,"X")+COUNTIF('AU05-29'!D16,"X")+COUNTIF('AU05-34'!D16,"X")+COUNTIF('AU05-36&7'!D16,"X")+COUNTIF('AU05-46'!D16,"X")+COUNTIF('AU05-50'!D16,"X")+COUNTIF('AU05-58'!D16,"X")+COUNTIF('AU05-60'!D16,"X")+COUNTIF('AU05-61'!D16,"X")+COUNTIF('AU05-68'!D16,"X")

Here is a picture that might help you to understand what i would like
to be done.
4643
This survey is on every one of the 16 worksheets but the first
worksheet (Summary 2004_5) is blank and i would like a summary of all
the "X" on all the other worksheets.
If at all possible, if a new worksheet is added or name is changed it
would automatically include that one aswell

Thanks in advance
Kieran


+-------------------------------------------------------------------+
|Filename: excelexample.jpg |
|Download: http://www.excelforum.com/attachment.php?postid=4643 |
+-------------------------------------------------------------------+

--
kmh987
------------------------------------------------------------------------
kmh987's Profile: http://www.excelforum.com/member.php...o&userid=33533
View this thread: http://www.excelforum.com/showthread...hreadid=533335

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Countif using the same cell on every sheet

Function CountACrossSheets(cell As String, testValue) As Long
Dim sh As Worksheet
Dim rng As Range
Dim tmp As Long
For Each sh In ThisWorkbook.Worksheets
If sh.Name < Range("A1").Parent.Name Then
Set rng = sh.Range(cell)
tmp = tmp + Application.CountIf(rng, testValue)
End If
Next sh
CountACrossSheets = tmp
End Function


use like this

=CountAcrossSheets("D16","X")

it will count all sheets except the sheet the function is used in.


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"kmh987" wrote in
message ...

Is it possible to do a countif using the same cell reference for every
worksheet?

Like a shorthand of doing but i would also like to covert it to VB
code

=COUNTIF('AU05-02'!D16,"X")+COUNTIF('AU05-09'!D16,"X")+COUNTIF('AU05-12'!D16
,"X")+COUNTIF('AU05-14'!D16,"X")+COUNTIF('AU05-23'!D16,"X")+COUNTIF('AU04-24
'!D16,"X")+COUNTIF('AU05-29'!D16,"X")+COUNTIF('AU05-34'!D16,"X")+COUNTIF('AU
05-36&7'!D16,"X")+COUNTIF('AU05-46'!D16,"X")+COUNTIF('AU05-50'!D16,"X")+COUN
TIF('AU05-58'!D16,"X")+COUNTIF('AU05-60'!D16,"X")+COUNTIF('AU05-61'!D16,"X")
+COUNTIF('AU05-68'!D16,"X")

Here is a picture that might help you to understand what i would like
to be done.
4643
This survey is on every one of the 16 worksheets but the first
worksheet (Summary 2004_5) is blank and i would like a summary of all
the "X" on all the other worksheets.
If at all possible, if a new worksheet is added or name is changed it
would automatically include that one aswell

Thanks in advance
Kieran


+-------------------------------------------------------------------+
|Filename: excelexample.jpg |
|Download: http://www.excelforum.com/attachment.php?postid=4643 |
+-------------------------------------------------------------------+

--
kmh987
------------------------------------------------------------------------
kmh987's Profile:

http://www.excelforum.com/member.php...o&userid=33533
View this thread: http://www.excelforum.com/showthread...hreadid=533335



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Countif using the same cell on every sheet

slight adjustment

Function CountACrossSheets(cell As String, testValue) As Long
Dim sh As Worksheet
Dim rng As Range
Dim tmp As Long

For Each sh In ThisWorkbook.Worksheets
If sh.Name < Application.Caller.Parent.Name Then
Set rng = sh.Range(cell)
tmp = tmp + Application.CountIf(rng, testValue)
End If
Next sh
CountACrossSheets = tmp
End Function


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"kmh987" wrote in
message ...

Is it possible to do a countif using the same cell reference for every
worksheet?

Like a shorthand of doing but i would also like to covert it to VB
code

=COUNTIF('AU05-02'!D16,"X")+COUNTIF('AU05-09'!D16,"X")+COUNTIF('AU05-12'!D16
,"X")+COUNTIF('AU05-14'!D16,"X")+COUNTIF('AU05-23'!D16,"X")+COUNTIF('AU04-24
'!D16,"X")+COUNTIF('AU05-29'!D16,"X")+COUNTIF('AU05-34'!D16,"X")+COUNTIF('AU
05-36&7'!D16,"X")+COUNTIF('AU05-46'!D16,"X")+COUNTIF('AU05-50'!D16,"X")+COUN
TIF('AU05-58'!D16,"X")+COUNTIF('AU05-60'!D16,"X")+COUNTIF('AU05-61'!D16,"X")
+COUNTIF('AU05-68'!D16,"X")

Here is a picture that might help you to understand what i would like
to be done.
4643
This survey is on every one of the 16 worksheets but the first
worksheet (Summary 2004_5) is blank and i would like a summary of all
the "X" on all the other worksheets.
If at all possible, if a new worksheet is added or name is changed it
would automatically include that one aswell

Thanks in advance
Kieran


+-------------------------------------------------------------------+
|Filename: excelexample.jpg |
|Download: http://www.excelforum.com/attachment.php?postid=4643 |
+-------------------------------------------------------------------+

--
kmh987
------------------------------------------------------------------------
kmh987's Profile:

http://www.excelforum.com/member.php...o&userid=33533
View this thread: http://www.excelforum.com/showthread...hreadid=533335



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Countif using the same cell on every sheet


great thanks for your help i really appreciate it
Kieran


--
kmh987
------------------------------------------------------------------------
kmh987's Profile: http://www.excelforum.com/member.php...o&userid=33533
View this thread: http://www.excelforum.com/showthread...hreadid=533335

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Countif using the same cell on every sheet


Help i have entered the VB code and then i go to enter the formula into
the cell but i get a #NAME? error and i can't work out why??


--
kmh987
------------------------------------------------------------------------
kmh987's Profile: http://www.excelforum.com/member.php...o&userid=33533
View this thread: http://www.excelforum.com/showthread...hreadid=533335



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Countif using the same cell on every sheet

You need to put the VBA code in a standard code module, not in a worksheet
code module, nor ThisWorkbook.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"kmh987" wrote in
message ...

Help i have entered the VB code and then i go to enter the formula into
the cell but i get a #NAME? error and i can't work out why??


--
kmh987
------------------------------------------------------------------------
kmh987's Profile:

http://www.excelforum.com/member.php...o&userid=33533
View this thread: http://www.excelforum.com/showthread...hreadid=533335



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Countif using the same cell on every sheet


you are an absolute legend
thanks alo

--
kmh98
-----------------------------------------------------------------------
kmh987's Profile: http://www.excelforum.com/member.php...fo&userid=3353
View this thread: http://www.excelforum.com/showthread.php?threadid=53333

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
Countif and Sumif with refrence value a Cell on another Sheet in theWorkbook Mike 215 Excel Discussion (Misc queries) 3 September 3rd 09 03:51 AM
using countif on sheet 2 grizzly6969 Excel Discussion (Misc queries) 6 March 27th 09 05:18 AM
Countif using the same cell on every sheet kmh987 Excel Worksheet Functions 8 April 18th 06 02:50 PM
countif more than one sheet/tab and sumproduct BSantos Excel Worksheet Functions 1 February 23rd 06 06:20 PM
COUNTIF or not to COUNTIF on a range in another sheet Ellie Excel Worksheet Functions 4 September 15th 05 10:06 PM


All times are GMT +1. The time now is 07:45 AM.

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"