Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default "Counter" in macro

You don't need to use UCASE or its equivalent in the WorksheetFunction
method as the COUNTIF function is not case sensitive; however, applying the
TRIM function is a little more problematic (although I would point out the
your coded solution is not a direct equivalent of the worksheet function
method you posted originally). Let me think about that one a little bit.

--
Rick (MVP - Excel)


"Mike H" wrote in message
...
Ron,

Similar repone to Rick. Why have you included Application when it works
without.

Like yourself I've posted this answer many times to have the OP bounce
back
'It doesn't get all the values I expect......" and almost invariably it's
a
case and/or rogue space issue so how can you include UCASE(Trim in the
worksheet.function method?

Mike

"Ron de Bruin" wrote:

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)



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
Macro for a "counter" Lineman116 Excel Discussion (Misc queries) 2 March 11th 09 07:37 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Read ".dll" files, the Macro "work flow" and the actual values of the variables when Macro is running [email protected] Excel Programming 5 May 16th 07 08:18 PM
How do I set up a "roll over" counter in excel 2003? mcorson Excel Worksheet Functions 1 March 6th 07 09:10 PM
multiple file uploading - runtime error'13': type mismatch "While Counter <= UBound(FName)" Sinner Excel Discussion (Misc queries) 3 March 1st 07 09:44 AM


All times are GMT +1. The time now is 05:38 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"