Using Countif on Array

  • Thread starter Thread starter ExcelMonkey
  • Start date Start date
E

ExcelMonkey

Can't seem to get this to work. Run-time Error 438 - Object does not support
property or method. Why is this? RowNumberArray has numbers in it.

NumOccurences = Application.WorkshseetFunction.CountIf(RowNumberArray,
RowNumberArray(X))

?RowNumberArray(X)
7
?UBOUND(RowNumberArray)
5793
?LBOUND(RowNumberArray)
0

Thanks
EM
 
Why don't you just loop. Probably more efficient than calling a worksheet
function

count = 0
for i = 0 to (UBOUND(RowNumberArray) - 1)
if RowNumberArray(X) = RowNumberArray(i) then
count = count + 1
end if
next i
 
ExcelMonkey said:
Can't seem to get this to work. Run-time Error 438 - Object does not support
property or method. Why is this? RowNumberArray has numbers in it.

NumOccurences = Application.WorkshseetFunction.CountIf(RowNumberArray,
RowNumberArray(X))

The worksheet function COUNTIF doesn't accept arrays. If you don't want
to loop as suggested, if the functions in the freely downloadable file
at http://home.pacbell.net/beban are available to your workbook

NumOccurrences = ArrayCountIf(RowNumberArray, RowNumberArray(X))

Alan Beban
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top