View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default "Counter" in macro

hi mike

I also use a macro if I want to do this but maybe one of the formula guys will jump in with
a good solution



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Mike H" wrote in message ...
As in

Bootcamp
Bootleg
Deboochery (Ok so I spelt that wrong)

Mike

"Rick Rothstein" wrote:

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" wrote in message
...
To duplicate Mike's macro use

Count = Application.WorksheetFunction.CountIf(Range("A1:D2 00"), "*Boo*")


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Rick Rothstein" wrote in message
...
But 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:D2 00"), "Boo")
MsgBox Count
End Sub

--
Rick (MVP - Excel)