Re: "Counter" in macro
- From: "Rick Rothstein" <rick.newsNO.SPAM@xxxxxxxxxxxxxxxxxx>
- Date: Mon, 15 Sep 2008 14:21:15 -0400
I don't think so. This line from Mike's posting...
If UCase(Trim(c.Value)) = "BOO" Then
tests the entire cell's (upper-cased) content for being equal to the search word ("BOO")... your asterisks allow the search word to be part of a larger piece of text and still produce a match to be counted.
--
Rick (MVP - Excel)
"Ron de Bruin" <rondebruin@xxxxxxxxxxxx> wrote in message news:uNFzc41FJHA.1000@xxxxxxxxxxxxxxxxxxxxxxx
To duplicate Mike's macro use
Count = Application.WorksheetFunction.CountIf(Range("A1:D200"), "*Boo*")
--
Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm
"Rick Rothstein" <rick.newsNO.SPAM@xxxxxxxxxxxxxxxxxx> wrote in message news:uNqNd01FJHA.2252@xxxxxxxxxxxxxxxxxxxxxxxBut if you have a particular reson for wanting a macro then use this
Sub marine()
Dim Myrange As Range
Set Myrange = Range("A1:D200")
For Each c In Myrange
If UCase(Trim(c.Value)) = "BOO" Then
Count = Count + 1
End If
Next
MsgBox Count
End Sub
Or...
Sub marine() ' <g>
Dim Count As Long
Count = Application.WorksheetFunction.CountIf(Range("A1:D200"), "Boo")
MsgBox Count
End Sub
--
Rick (MVP - Excel)
.
- Follow-Ups:
- Re: "Counter" in macro
- From: Mike H
- Re: "Counter" in macro
- From: Ron de Bruin
- Re: "Counter" in macro
- References:
- "Counter" in macro
- From: bobkap
- RE: "Counter" in macro
- From: Mike H
- Re: "Counter" in macro
- From: Rick Rothstein
- Re: "Counter" in macro
- From: Ron de Bruin
- "Counter" in macro
- Prev by Date: Re: "Counter" in macro
- Next by Date: How can I make a cell to flash?
- Previous by thread: Re: "Counter" in macro
- Next by thread: Re: "Counter" in macro
- Index(es):