Unable to get the countifs property of the worksheetfunction class

Godders199

Active Member
Joined
Mar 2, 2017
Messages
313
Office Version
  1. 2013
Hi, can anyone tell me what I am doing wrong here, I keepgetting the following error “Unable to get the countifs property of theworksheetfunction class

Dim lastrowcolumnz As Long
lastrowcolumnz = Range("a" &Rows.Count).End(xlUp).Row
For i = 2 To lastrowcolumnz
Cells(i, 20) =Application.WorksheetFunction.CountIfs(Sheets("HomeInsurance").Range("B:B"), Sheets("Summary").Cells(i,1) > 0, Cells(i, 20).Value = "Home Insurance", "")
Next i
If I type the formula in the cell it returns the results,just can get the vba code to work.

Have looked at loads of examples, just cant get past thiserror



thanks
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
That is not a valid formula.
What are you trying to do?
 
Upvote 0
Hi i am trying to get the following formula in column t to last row

=IF(COUNTIFS('HomeInsurance'!B:B,Summary!A2)>0,"Home Insurance","")
 
Upvote 0
Try
Code:
Dim lastrowcolumnz As Long
lastrowcolumnz = Range("a" & Rows.Count).End(xlUp).Row
With Range("T2:T" & lastrowcolumnz)
   .Formula = "=if(CountIfs('HomeInsurance'!B:B, Summary!A2)> 0,""Home Insurance"")"
   .Value = .Value
End With
 
Upvote 0
Just FYI, the equivalent VBA would have been:

Code:
If Application.WorksheetFunction.CountIf(Sheets("HomeInsurance").Range("B:B"), Sheets("Summary").Cells(i,1)) > 0 Then
Cells(i, 20).Value = "Home Insurance"
Else
Cells(i, 20) = ""
End If
 
Upvote 0
Your welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,797
Messages
6,121,629
Members
449,041
Latest member
Postman24

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