Use this:
iCountOfApples = ExcApp.WorksheetFunction.CountIf(ObjectRange,StringToFind)
where
iCountOfApples
- id the integer variable
ExcApp
- is the object variable, type of: the instance of MS Excel Application
ObjectRange
- is the object variable, type of: Range
StringToFind
- is the string variable