+ Reply to Thread
Results 1 to 4 of 4

Unable to get countIF property of worksheetFunction class

  1. #1
    Registered User
    Join Date
    04-14-2010
    Location
    NZ
    MS-Off Ver
    2007,2010
    Posts
    86

    Unable to get countIF property of worksheetFunction class

    I have a worksheet, where the user selects a csv file to open, then the macro runs comparing values between the two worksheets

    the issue i run into, is that on the WorksheetFunction.CountIf line, i get the above error.

    If i change the Vrng to Valraw.Cells, then it works fine (although it takes a while to run)
    I tested this in excel 07 last night, which worked fine while it was using Vrng - it's excel 03 (at work) where it fails.

    Please Login or Register  to view this content.
    Last edited by Deamo; 06-10-2010 at 09:35 PM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Unable to get countIF property of worksheetFunction class

    Could be a few things but given you get to the COUNTIF I presume Vrng is ok, in which case I suspect the issue will come down to the fact that Vrng is probably non-contiguous, ie:

    =COUNTIF(A1:A10,"apple")

    is ok whereas

    =COUNTIF(A1:A3,A7,A9,"Apple")

    is not.

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Unable to get countIF property of worksheetFunction class

    I don't see a problem obvious to me but I would debug this by setting a breakpoint at the following line:

    Please Login or Register  to view this content.
    step past it one instruction, and then bring up the Immediate Window and then use the command

    print Vrng.Address

    and see if the result is what you expect.

    As for your workaround, instead of using ValRaw as the argument, try ValRaw.UsedRange. It may speed things up.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Registered User
    Join Date
    04-14-2010
    Location
    NZ
    MS-Off Ver
    2007,2010
    Posts
    86

    Re: Unable to get countIF property of worksheetFunction class

    Thanks both of you for the help.
    Does appear to be an issue with getting it to look at the non-contiguous range.

    i've reset that problem line to..

    Please Login or Register  to view this content.
    even though the whole range is specified, only those cells that are visible are being compared.
    May not be a great work around in the grand scheme of things.. but it works (until it fails that is ;P ).

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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