+ Reply to Thread
Results 1 to 2 of 2

Function CountIF Error 1004

Hybrid View

  1. #1
    Registered User
    Join Date
    04-04-2015
    Location
    Vancouver, Canada
    MS-Off Ver
    Office 365
    Posts
    88

    Function CountIF Error 1004

    Hi,
    I am getting error 1004: Unable to get countif property of the worksheetfunction class?

        Dim rngCard As Range
        Set rngCard = ActiveCell
        
        Dim rngPlus As Range
        Dim cntPlus As Long
        Set rngPlus = Range("BN5:CL5, BN7:CL7, BN9:CL9, BN11:CL11")
        cntPlus = Application.WorksheetFunction.CountIf(rngPlus, "+")
    I assumed this will work because before I had:

        Dim rngCard As Range
        Set rngCard = ActiveCell
        
        Dim rngPlus As Range
        Dim cntPlus As Long
        Set rngPlus = Range("BN5:CL5, BN7:CL7, BN9:CL9, BN11:CL11")
        cntPlus = Application.WorksheetFunction.CountA(rngPlus)
    However, it does not work. How do I get countif to work? Please help.

  2. #2
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Function CountIF Error 1004

    Maybe
    Sub Test()
        Dim rngPlus As Range
        Dim cell As Range
        Dim xCount As Integer
        
        xCount = 0
        
        Set rngPlus = Range("BN5:CL5, BN7:CL7, BN9:CL9, BN11:CL11")
        
        For Each cell In rngPlus
            If cell.Value = "+" Then
                xCount = xCount + 1
            End If
        Next cell
        
        MsgBox xCount
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Error 1004 - "Unable to get the CountIf property of the WorksheetFunction class"
    By kknb0800 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-27-2015, 12:41 AM
  2. [SOLVED] offset function not populating - run time 1004 error
    By Sc0tt1e in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-29-2014, 12:24 PM
  3. [SOLVED] LEFT function - error 1004 ?
    By Lukael in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-25-2014, 07:51 AM
  4. IF statement returns 1004 error when trying to add function to a cell using VBA
    By chairmaker in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-06-2013, 03:03 PM
  5. Application Error 1004 on Search Update Function
    By stoey in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-30-2011, 08:40 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1