Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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" wrote in message
...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default issue with countif in vba

Thanks.

"Bob Phillips" wrote in message
...
myFormula = "=COUNTIF(E2:E" & LastRow - 1 & ",""" & currentCDBID & """)"


--

HTH

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


"Xavier Minet" wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Countif function Issue justkar4u Excel Worksheet Functions 10 February 22nd 11 07:33 PM
I have the following issue with COUNTIF Fab Excel Worksheet Functions 2 September 23rd 09 12:14 AM
COUNTIF Function issue Gweduc Excel Worksheet Functions 5 July 30th 09 10:43 PM
Countif issue Stuck Excel Worksheet Functions 3 June 23rd 09 10:29 PM
SumProduct CountIF issue JimG Excel Worksheet Functions 5 August 3rd 08 06:20 AM


All times are GMT +1. The time now is 05:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"