PC Review


Reply
Thread Tools Rate Thread

countif - in an entire workbook

 
 
Johnnyboy5
Guest
Posts: n/a
 
      25th Sep 2010
Hi I need some kind formula to Countif (all the cells in whole
workbook / worksheet) for a certain text string.

johnnboy

 
Reply With Quote
 
 
 
 
James Ravenswood
Guest
Posts: n/a
 
      26th Sep 2010
On Sep 25, 4:33*pm, Johnnyboy5 <intermediatec...@gmail.com> wrote:
> Hi *I need some kind formula to Countif (all the cells in whole
> workbook / worksheet) for a certain text string.
>
> johnnboy


This will count all the cells in all the worksheets containing "hello"

Sub SuperCount()
Dim r As Range
SuperCounter = 0
s = "hello"
For Each sh In Sheets
sh.Activate
For Each r In ActiveSheet.UsedRange
If r.Value = s Then
SuperCounter = SuperCounter + 1
End If
Next
Next
MsgBox SuperCounter
End Sub
 
Reply With Quote
 
Johnnyboy5
Guest
Posts: n/a
 
      26th Sep 2010
On 26 Sep, 01:09, James Ravenswood <james.ravensw...@gmail.com> wrote:
> On Sep 25, 4:33*pm, Johnnyboy5 <intermediatec...@gmail.com> wrote:
>
> > Hi *I need some kind formula to Countif (all the cells in whole
> > workbook / worksheet) for a certain text string.

>
> > johnnboy

>
> This will count all the cells in all the worksheets containing "hello"
>
> Sub SuperCount()
> Dim r As Range
> SuperCounter = 0
> s = "hello"
> For Each sh In Sheets
> * * sh.Activate
> * * For Each r In ActiveSheet.UsedRange
> * * * * * * If r.Value = s Then
> * * * * * * * * SuperCounter = SuperCounter + 1
> * * * * * * End If
> * * Next
> Next
> MsgBox SuperCounter
> End Sub


Thanks that works just great, I can see what I really need now, to
just count all the "hello" in the same column "n" in each worksheet
with the workbook.

Can it be done ?

thanks

Johnny
 
Reply With Quote
 
Don Guillett Excel MVP
Guest
Posts: n/a
 
      26th Sep 2010
On Sep 26, 4:30*am, Johnnyboy5 <intermediatec...@gmail.com> wrote:
> On 26 Sep, 01:09, James Ravenswood <james.ravensw...@gmail.com> wrote:
>
>
>
>
>
> > On Sep 25, 4:33*pm, Johnnyboy5 <intermediatec...@gmail.com> wrote:

>
> > > Hi *I need some kind formula to Countif (all the cells in whole
> > > workbook / worksheet) for a certain text string.

>
> > > johnnboy

>
> > This will count all the cells in all the worksheets containing "hello"

>
> > Sub SuperCount()
> > Dim r As Range
> > SuperCounter = 0
> > s = "hello"
> > For Each sh In Sheets
> > * * sh.Activate
> > * * For Each r In ActiveSheet.UsedRange
> > * * * * * * If r.Value = s Then
> > * * * * * * * * SuperCounter = SuperCounter + 1
> > * * * * * * End If
> > * * Next
> > Next
> > MsgBox SuperCounter
> > End Sub

>
> Thanks *that works just great, I can see what I really need now, *to
> just count *all the "hello" in the same column "n" *in each worksheet
> with the workbook.
>
> Can it be done ?
>
> thanks
>
> Johnny- Hide quoted text -
>
> - Show quoted text -


This might be quicker than a loop for text.

Option Explicit
Sub countjune()
Dim ws As Worksheet
Dim mycol As Range
Dim mc As Long
For Each ws In Worksheets
Set mycol = ws.Columns("N")
mc = mc + Application.CountIf(mycol, "Hello")
Next ws
MsgBox mc
End Sub
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Name an Entire Workbook =?Utf-8?B?TmFCZWxsRkw=?= Microsoft Excel Misc 3 15th Nov 2007 03:49 PM
Name an Entire Workbook =?Utf-8?B?TmFCZWxsRkw=?= Microsoft Excel Misc 0 15th Nov 2007 02:24 PM
How to Copy entire Worksheet from Workbook S to Workbook D =?Utf-8?B?a3Jpcw==?= Microsoft Excel Programming 3 20th Jun 2007 02:03 PM
countif across entire workbook =?Utf-8?B?RGF2ZSBCcmVpdGVuYmFjaA==?= Microsoft Excel Worksheet Functions 1 22nd Sep 2006 09:50 PM
Printing Entire Workbook Chris Watling Microsoft Excel Crashes 0 10th Oct 2003 03:12 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:00 PM.