COUNTIFS issue

beedistinct

Board Regular
Joined
Jun 24, 2011
Messages
62
I'm trying to take an average of columns of numbers corresponding to another date column if that has a valid date or blanks.
I figured AVERAGEIFS wouldn't work here because there is no way I could provide an OR condition. So I decided to use SUMIFS and COUNTIFS instead.
WHat I'm doing is first summing the numbers with valid dates and counting them and then summing the numbers for which I have a blank date and counting them. Then I'm adding the sums and the counts to get an average.
None of it seems to be working. The sumIFS work fine and apparentlt COUNTIFs too but when I try to add the two counts it gives me run-time error 13 Type mismtach.
Code:
CountLocked2011 = Application.CountIfs(AverageRange, StateRange, "<>Draft", SubmitRange, ">=1/1/2011", SubmitRange, "<6/1/2011", LockedRange, "Yes") 
CountSpaceLocked2011 = Application.CountIfs(AverageRange, StateRange, "<>Draft", SubmitRange, "", LockedRange, "Yes")
 
[B]CountSpaceLocked2011 = CountSpaceLocked2011 + CountLocked2011[/B]

Please help resolve this run-time error or let me know how can I use an OR condition in AVERAGEFS.
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Have you checked the values being returned in lines 1 and 2?

If the first two lines are working ok, but the third is failing due to type mismatch, you could try forcing VBA to see them as integers (or other types, as required)

Try wrapping each varable in cInt, i.e. CountSpaceLocked2011 = cint(CountSpaceLocked2011) + cint(CountLocked2011)
 
Upvote 0
Have you checked the values being returned in lines 1 and 2?

If the first two lines are working ok, but the third is failing due to type mismatch, you could try forcing VBA to see them as integers (or other types, as required)

Try wrapping each varable in cInt, i.e. CountSpaceLocked2011 = cint(CountSpaceLocked2011) + cint(CountLocked2011)

Thanks! I relooked at my formula. The syntax was wrong for COUNTIFS, I was using the first parameter as an AverageRange which is not required. COUNTIFS only requires the Criteria Range.

Thank you!
 
Upvote 0

Forum statistics

Threads
1,224,582
Messages
6,179,670
Members
452,936
Latest member
anamikabhargaw

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