+ Reply to Thread
Results 1 to 12 of 12

Error 1004 - "Unable to get the CountIf property of the WorksheetFunction class"

  1. #1
    Registered User
    Join Date
    05-13-2010
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    20

    Error 1004 - "Unable to get the CountIf property of the WorksheetFunction class"

    Hi,

    I'm using the below code to remove duplicates. It reads the values in column N and if a duplicate is found, it deletes the values in columns A to G for the row in which the duplicate is found.


    Please Login or Register  to view this content.
    The issue is that it's working correctly up until a point where is throws the 1004 error - "Unable to get the CountIf property of the WorksheetFunction class"

    Any ideas what is causing this? Am I better off using another method?

    Thanks!

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Error 1004 - "Unable to get the CountIf property of the WorksheetFunction class"

    I think you have to put "=" & range("n" & x).text
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Registered User
    Join Date
    05-13-2010
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Error 1004 - "Unable to get the CountIf property of the WorksheetFunction class"

    thanks for the quick reply. Unfortunately I get the same error

  4. #4
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Error 1004 - "Unable to get the CountIf property of the WorksheetFunction class"

    Can you attach the data?????

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Error 1004 - "Unable to get the CountIf property of the WorksheetFunction class"

    When I run it my test, I did not get an error.

    May be,change

    Please Login or Register  to view this content.
    INTO

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    05-13-2010
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Error 1004 - "Unable to get the CountIf property of the WorksheetFunction class"

    both - Just trying different things and I've pin pointed the reason why I get the error. It's down to the cell contents length being greater than 254 characters.

    The question now is if it's possible to get around this without having to restrict the length of the string within a cell?

  7. #7
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Error 1004 - "Unable to get the CountIf property of the WorksheetFunction class"

    Google what you've just asked us

  8. #8
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Error 1004 - "Unable to get the CountIf property of the WorksheetFunction class"

    Tyre this..
    Please Login or Register  to view this content.
    Regards,
    Vikas Gautam
    Excel-buzz.blogspot.com

    Excel is not a matter of Experience, its a matter of Application.

    Say Thanks, Click * Add Reputation

  9. #9
    Registered User
    Join Date
    05-13-2010
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Error 1004 - "Unable to get the CountIf property of the WorksheetFunction class"

    Thanks Vikas but it still errors at the same point as before as the cell string length is greater than 254. This is a limitation of using the countif function

  10. #10
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Error 1004 - "Unable to get the CountIf property of the WorksheetFunction class"

    If you are deleting duplicates, why not just add the range to an array set arr()=range("a1:a1000") then itterate it, putting the values into a dictionary, using the key to detect the dupes, then delete the row.

  11. #11
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Error 1004 - "Unable to get the CountIf property of the WorksheetFunction class"

    Here is a tested and complete workaround of what you need..
    Please Login or Register  to view this content.
    Last edited by Vikas_Gautam; 09-12-2014 at 12:01 PM.

  12. #12
    Registered User
    Join Date
    09-17-2014
    Location
    Adelaide
    MS-Off Ver
    2010
    Posts
    1

    Re: Error 1004 - "Unable to get the CountIf property of the WorksheetFunction class"

    Hi

    I have the same problem but I cannot understand how from the information posted how Range("H1:H" & LastRow).Value = Evaluate("index(MATCH(N1:N" & LastRow & ", N1:N" & LastRow & ", 0),)") allows you to change ther CountIf range from column "N" to column "B"?

    How does this work so i can apply the logic to my problem.

    My code is this:

    For Each List1Item In List1
    'Check if the value of the List1Item in the range occurs more than once
    If Application.WorksheetFunction.CountIf(List1, List1Item.Value) > 1 Then
    List1Item.Interior.ColorIndex = 36
    Dup = Dup + 1
    End If
    Next List1Item
    If Dup > 0 Then
    MsgBox "List 1 had " & Dup / 2 & " duplicates highlighted in yellow!", , "Duplicates Found & Marked in List 1"
    End If

    List1 is a named range

+ 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. Ms-excel error '1004':"Unable to get the Paste property of the Pictures class"
    By japortella in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-26-2014, 08:50 AM
  2. Run - time error '1004': Unable to get the Sum property of WorksheetFunction class
    By dylanrose in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-06-2013, 10:25 AM
  3. Run-time Error 1004: Unable to get the VLookup property of the WorksheetFunction class
    By sridhar_neel in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-10-2012, 04:21 AM
  4. Run-time error 1004; "Unable to set the Hidden property of the Range Class"
    By danimal_time in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-22-2012, 01:06 PM
  5. run-time error '1004 Unable to get Match property of WorksheetFunction class
    By exl044 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-08-2010, 02:23 AM

Tags for this Thread

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