+ Reply to Thread
Results 1 to 3 of 3

issue with countif in vba

  1. #1
    Xavier Minet
    Guest

    issue with countif in vba

    Hi,

    I am trying to identify duplicate values in an Excel 2003 column. If I am
    using the following code:

    myFormula = "=COUNTIF(E2:E" & LastRow - 1 & ",""=" & currentCDBID & """)"
    countDUP = Evaluate(myFormula)
    If countDUP > 1 Then ... rest of my code...

    countDUP always returns "0" as result of the evaluate call (and in my
    spreadsheet there are obviously duplicate values)

    I thought I spotted the cause of the issue: countif requires a ";" as
    separator between the range and the criteria. So I transformed my code into:

    myFormula = "=COUNTIF(E2:E" & LastRow - 1 & ";""=" & currentCDBID & """)"
    countDUP = Evaluate(myFormula)
    If countDUP > 1 Then ... rest of my code...

    And now countDUP always contains "Error 2015" which refers to a type
    mismatch.

    Does anyone know what is the cause of my problem ?

    Any help would be appreciated.


    Xavier



  2. #2
    Bob Phillips
    Guest

    Re: issue with countif in vba

    myFormula = "=COUNTIF(E2:E" & LastRow - 1 & ",""" & currentCDBID & """)"


    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Xavier Minet" <[email protected]> wrote in message
    news:%[email protected]...
    > Hi,
    >
    > I am trying to identify duplicate values in an Excel 2003 column. If I am
    > using the following code:
    >
    > myFormula = "=COUNTIF(E2:E" & LastRow - 1 & ",""=" & currentCDBID & """)"
    > countDUP = Evaluate(myFormula)
    > If countDUP > 1 Then ... rest of my code...
    >
    > countDUP always returns "0" as result of the evaluate call (and in my
    > spreadsheet there are obviously duplicate values)
    >
    > I thought I spotted the cause of the issue: countif requires a ";" as
    > separator between the range and the criteria. So I transformed my code

    into:
    >
    > myFormula = "=COUNTIF(E2:E" & LastRow - 1 & ";""=" & currentCDBID & """)"
    > countDUP = Evaluate(myFormula)
    > If countDUP > 1 Then ... rest of my code...
    >
    > And now countDUP always contains "Error 2015" which refers to a type
    > mismatch.
    >
    > Does anyone know what is the cause of my problem ?
    >
    > Any help would be appreciated.
    >
    >
    > Xavier
    >
    >




  3. #3
    Xavier
    Guest

    Re: issue with countif in vba

    Thanks.

    "Bob Phillips" <[email protected]> wrote in message
    news:%[email protected]...
    > myFormula = "=COUNTIF(E2:E" & LastRow - 1 & ",""" & currentCDBID & """)"
    >
    >
    > --
    >
    > HTH
    >
    > RP
    > (remove nothere from the email address if mailing direct)
    >
    >
    > "Xavier Minet" <[email protected]> wrote in message
    > news:%[email protected]...
    >> Hi,
    >>
    >> I am trying to identify duplicate values in an Excel 2003 column. If I
    >> am
    >> using the following code:
    >>
    >> myFormula = "=COUNTIF(E2:E" & LastRow - 1 & ",""=" & currentCDBID & """)"
    >> countDUP = Evaluate(myFormula)
    >> If countDUP > 1 Then ... rest of my code...
    >>
    >> countDUP always returns "0" as result of the evaluate call (and in my
    >> spreadsheet there are obviously duplicate values)
    >>
    >> I thought I spotted the cause of the issue: countif requires a ";" as
    >> separator between the range and the criteria. So I transformed my code

    > into:
    >>
    >> myFormula = "=COUNTIF(E2:E" & LastRow - 1 & ";""=" & currentCDBID & """)"
    >> countDUP = Evaluate(myFormula)
    >> If countDUP > 1 Then ... rest of my code...
    >>
    >> And now countDUP always contains "Error 2015" which refers to a type
    >> mismatch.
    >>
    >> Does anyone know what is the cause of my problem ?
    >>
    >> Any help would be appreciated.
    >>
    >>
    >> Xavier
    >>
    >>

    >
    >




+ 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