COUNTIF using arrays

YasserKhalil

Well-known Member
Joined
Jun 24, 2010
Messages
852
Hello everyone
I am searching for UDF that do the same as COUNTIF but within arrays
I would store A2:E20 in an array and rely on the udf to do the countif or countifs
If possible I would like it to be more flexible to deal with one criteria or two or more ..
I imagine CountifsInArray(array,col num in array,criteria1,col num in array,criteria2 ...here if possible to be as COUNTIFS)
Here's sample to work on
Thanks advanced for help

Test
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Thanks for reply
The issue is not a problem with COUNTIFS itself
I can use it in worksheet directly and also using worksheet function built in feature
I have vba array which is a result of many operations and I don't deal at this point with ranges ..I am dealing with the arrays so I think of UDF to do the same task of COUNTIFS but to deal with VBA arrays
 
Upvote 0
Where in your test file are the expected outcomes? I can see where you have used COUNTIFS formulae, but what is the ultimate aim here?
 
Upvote 0
Thanks for reply
The ultimate aim in this line
I imagine CountifsInArray(array,col num in array,criteria1,col num in array,criteria2 ...here if possible to be as COUNTIFS)
Simply the same as COUNTIFS but to refer to an array not to a range >> That's all
 
Upvote 0
Have a look at this code
Code:
Sub Test()    Dim arr
    arr = Range("A2:E20").Value
    
    '=COUNTIF(B2:B20,"A")
    'This is used with ranges ...
    'Imagine ::::
    MsgBox COUNTIFINARRAY(arr, 2, "A")
    '>> 2 is the second column in the array and "A" is the criteria ..
End Sub
 
Upvote 0
You're still not providing actual expected results from this! Literally give us an example of a COUNTIFS and the result it would return!

Regardless, there is no difference between =COUNTIFS(B:B,"A") and your theoretical =Countifsarray(array, 2, "A") they would both just be counting the appearances of "A" in that column.
 
Upvote 0

Forum statistics

Threads
1,214,611
Messages
6,120,509
Members
448,967
Latest member
screechyboy79

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top