sheetspread
Well-known Member
- Joined
- Sep 19, 2005
- Messages
- 5,161
These two posts suggest it can't be done:
http://www.mrexcel.com/forum/excel-questions/672885-visual-basic-applications-countif-array.html
http://www.mrexcel.com/forum/excel-...lications]-count-number-occurances-array.html
But shg said:
I tried using evaluate sumproduct with a myarray (as variant) and couldn't get it to work.
Example: myarray = array("First","Second","Second","Third","Fourth")
then what would the countif(myarray,"second") syntax be? (the result should equal 2 counts)
The only other method I can think of is printing the array to a worksheet range (which doesn't require a loop), counting off that, then deleting.
http://www.mrexcel.com/forum/excel-questions/672885-visual-basic-applications-countif-array.html
http://www.mrexcel.com/forum/excel-...lications]-count-number-occurances-array.html
But shg said:
You can use worksheet functions in VBA, and could use WorksheetFunction.SumProduct for this. Some functions (CountIf, Rank, some others) work only with ranges (and IntelliSense will tell you), but SumProduct is happy with arrays.
I tried using evaluate sumproduct with a myarray (as variant) and couldn't get it to work.
Example: myarray = array("First","Second","Second","Third","Fourth")
then what would the countif(myarray,"second") syntax be? (the result should equal 2 counts)
The only other method I can think of is printing the array to a worksheet range (which doesn't require a loop), counting off that, then deleting.