Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Find and count occurrances


Dave Peterson Wrote:
Do you mean VBA or VB?

In a cell in a worksheet, I'd use:
=sum(countif(a:a,{"ok","ca","ng"})

In VBA, I'd use:

Option Explicit
Sub testme()
Dim myStr As Variant
Dim myTotal As Long
Dim iCtr As Long
Dim myRng As Range

Set myRng = ActiveSheet.Range("a:a")

myStr = Array("ok", "ca", "ng")
myTotal = 0
For iCtr = LBound(myStr) To UBound(myStr)
myTotal = myTotal + Application.CountIf(myRng, myStr(iCtr))
Next iCtr

MsgBox myTotal

End Sub

jmoss wrote:-

How can I count the number of times "OK" or "CA" or "NG" occur in a
column using VB? If the count of "NG" is equal to or greater than 20,
then don't print the worksheet.

--
jmoss-

--

Dave Peterson


Thanks for the code, this solved my problem! This is a great forum.




--
jmoss
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
Can't find topic for count Thomas Excel Discussion (Misc queries) 1 August 1st 06 11:53 PM
UDF is updateing cells on another sheet with count from current sheet. John Excel Discussion (Misc queries) 3 March 20th 06 03:58 PM
How do i count numbers and letters to find a total count of all Linda Excel Worksheet Functions 4 November 10th 05 04:51 PM
SUMPRODUCT Formula to Count Row of data Below Matched Criteria Sam via OfficeKB.com Excel Worksheet Functions 8 February 3rd 05 01:37 AM
Find Count of Items with certain criteria Tucson Guy Excel Discussion (Misc queries) 3 January 1st 05 02:11 PM


All times are GMT +1. The time now is 05:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"