Results 1 to 7 of 7

Countif in VBA returns wrong result.

Threaded View

  1. #1
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,481

    Countif in VBA returns wrong result.

    I have a list of date in A3:A13 and 1 date in C1
    All dates are formatted as dd/mm/yyy
    I try to countif as follow:
    =COUNTIF(A3:A13,"<="&C1)
    it is OK
    but try with VBA:
    Sub a()
    Dim adate As Range
    Dim n As Long
    Set adate = Range("A3:A13")
    n = WorksheetFunction.CountIf(ngay, "<=" & Range("C1"))
    Debug.Print n
    End Sub
    it returns wrong result
    See attachment.
    Anybody can help?
    Attached Files Attached Files
    Quang PT

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Countif returns faulty result
    By boboivan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-23-2015, 12:01 PM
  2. [SOLVED] formula returns wrong result
    By zplugger in forum Excel General
    Replies: 3
    Last Post: 03-12-2014, 01:17 PM
  3. Countif with 3 criteria and 3 exclusions returns wrong count
    By Kelly Linton-Selkirk in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-20-2014, 04:30 PM
  4. [SOLVED] Formula returns wrong result after midnight
    By ujpest in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 05-02-2013, 11:29 AM
  5. isblank & vlookup formula returns #n/a result and incorrect result
    By helpmeplease333 in forum Excel General
    Replies: 5
    Last Post: 05-06-2012, 11:41 PM
  6. vlookup based on random result returns incorrect result
    By rickat in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-05-2005, 09:20 AM
  7. [SOLVED] SUM returns wrong result
    By MarkN in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-19-2005, 11:05 PM

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