View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jon Peltier Jon Peltier is offline
external usenet poster
 
Posts: 6,582
Default VBA Type Mismatch

Use CountIf:

CentralTerms = Application.WorksheetFunction.CountIf(Terms_Market ,"Central")

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"John" wrote in message
...
I am trying to create a VBA function that looks at a Range of data on
Sheet2,
and uses the SumProduct function to return the number of occurances in
that
range. I keep getting a Type Mismatch error, but I can't figure out why.
Any
suggestions?

Sub TermsMarketBreakdown()
' Breaksdown the number of terms by Market
Dim CentralTerms
Dim Terms_Market
Set Terms_Market = Sheet2.Range("E2:E300")
CentralTerms = Application.WorksheetFunction.SumProduct((Terms_Ma rket =
"Central") * 1)
Cells(1, 1) = CentralTerms
End Sub