ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using Countif on Array (https://www.excelbanter.com/excel-programming/402211-using-countif-array.html)

ExcelMonkey

Using Countif on Array
 
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(RowNumberAr ray,
RowNumberArray(X))

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

Thanks
EM

joel

Using Countif on Array
 
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" wrote:

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(RowNumberAr ray,
RowNumberArray(X))

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

Thanks
EM


Alan Beban[_2_]

Using Countif on Array
 
ExcelMonkey wrote:
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(RowNumberAr ray,
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


All times are GMT +1. The time now is 08:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com