Error with Countifs function

raeannb

Board Regular
Joined
Jun 21, 2011
Messages
86
Hi! I'm having a CountIf problem (grrrr that darn function!) that I'm hoping someone could help me with. The following code is the 3rd or 4th version I've tried to get working, and they all return errors. Right now I'm getting a "Unable to get the CountIfs property of the WorksheetFunction class" error at the starred line:

HTML:
If Not WB2.Sheets(i).Rows(6).Find(What:="Start", LookAt:=xlPart, SearchOrder:=xlByColumns) Is Nothing Then
StartColumn = WB2.Sheets(i).Rows(6).Find(What:="Start", LookAt:=xlPart, SearchOrder:=xlByColumns).Column
NextColumn = WB2.Sheets(i).Rows(7).Find(What:="Next", LookAt:=xlPart, SearchOrder:=xlByColumns).Column
Set myRange = WB2.Sheets(i).Range(WB2.Sheets(i).Cells(j, StartColumn), WB2.Sheets(i).Cells(j, NextColumn - 1))
If IsEmpty(WB1.Sheets(2).Range("L" & SiteRow)) = True Then
a = WorksheetFunction.CountIfs(myRange, "<>" & "NC", "<>" & "NA", "<>" & "") *****Error here
b = WorksheetFunction.CountIf(myRange, "<>" & "NA")
WB1.Sheets(2).Range("L" & SiteRow).Value = a & "/" & b
End If
End If

The range is contigious, so that shouldn't be the issue...any thoughts? Thank you!!
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
It's the same syntax as in a cell - you need to repeat the range for each criterion:
Code:
a = WorksheetFunction.CountIfs(myRange, "<>NC", myRange, "<>NA", myRange, "<>" & "")
 
Upvote 0

Forum statistics

Threads
1,215,009
Messages
6,122,674
Members
449,091
Latest member
peppernaut

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