+ Reply to Thread
Results 1 to 17 of 17

Struggling with COUNTIFS function returning 0 when value expected

  1. #1
    Registered User
    Join Date
    07-02-2014
    Location
    Southwest, England
    MS-Off Ver
    Office 2010
    Posts
    12

    Struggling with COUNTIFS function returning 0 when value expected

    Hi guys

    Sorry if this has been covered before, I trawled through as many threads as possible to try and resolve before posting.

    I have a sub trying to populate metrics from a worksheet of raw data and inherited it with various excel formulae embedded in subsequent sheets. My solution so far works ok to a point, but for some reason when I start the next phase of the code, I'm not getting the results I expect. I've copied the sub initial dim lines and the first lines of the code that work ok. In the second extract i've copied in the line i'm having trouble with. Grateful for any help with possible solutions.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    p.s. first post, so apologies if I've posted this wrong!

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Struggling with COUNTIFS function returning 0 when value expected

    Hard to say without seeing data.

    Do you get the right result if manually entering the COUNTIF formula?
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    07-02-2014
    Location
    Southwest, England
    MS-Off Ver
    Office 2010
    Posts
    12

    Re: Struggling with COUNTIFS function returning 0 when value expected

    Hi Andy

    Yes, the formula works fine when entered directly into a cell in one of the worksheets. What data extract would help?

    Thanks
    Dave

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Struggling with COUNTIFS function returning 0 when value expected

    Any that allows us to test and investigate. Dummy data is file as long as it demostrates the problem.

  5. #5
    Registered User
    Join Date
    07-02-2014
    Location
    Southwest, England
    MS-Off Ver
    Office 2010
    Posts
    12

    Re: Struggling with COUNTIFS function returning 0 when value expected

    Unfortunately I'm limited as to what I can upload from work PC, are there any good workarounds for posting something useful that you are aware of? If not I'll email home and upload overnight.

    Thanks for your interest and assistance.

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Struggling with COUNTIFS function returning 0 when value expected

    Probably easiest to put something together at home and post later

  7. #7
    Registered User
    Join Date
    07-02-2014
    Location
    Southwest, England
    MS-Off Ver
    Office 2010
    Posts
    12

    Re: Struggling with COUNTIFS function returning 0 when value expected

    Thanks Andy, will do.

  8. #8
    Registered User
    Join Date
    07-02-2014
    Location
    Southwest, England
    MS-Off Ver
    Office 2010
    Posts
    12

    Re: Struggling with COUNTIFS function returning 0 when value expected

    I'm not sure if this attachment will work, but giving it a try.

    Metrics.xlsm

  9. #9
    Registered User
    Join Date
    07-02-2014
    Location
    Southwest, England
    MS-Off Ver
    Office 2010
    Posts
    12

    Re: Struggling with COUNTIFS function returning 0 when value expected

    Sorry guys, shameless thread-bump. Wondered it the attempted attachment worked ok and whether it had provided any further clarity on the problem.

    Thanks

  10. #10
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Struggling with COUNTIFS function returning 0 when value expected

    I get overflow error straight away. Should there be data in column A of rawdata sheet?

  11. #11
    Registered User
    Join Date
    07-02-2014
    Location
    Southwest, England
    MS-Off Ver
    Office 2010
    Posts
    12

    Re: Struggling with COUNTIFS function returning 0 when value expected

    Sorry Andy, got carried away sanitising the information. Yes, there would normally be data in column A and I thought I had changed it to include the first letter of the column B index, but obviously forgot that, i'll re-upload in a sec

  12. #12
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Struggling with COUNTIFS function returning 0 when value expected

    Can you also explain which of the lines is causing the problem?

  13. #13
    Registered User
    Join Date
    07-02-2014
    Location
    Southwest, England
    MS-Off Ver
    Office 2010
    Posts
    12

    Re: Struggling with COUNTIFS function returning 0 when value expected

    sorry about the last upload, try this one...Metrics.xlsm

  14. #14
    Registered User
    Join Date
    07-02-2014
    Location
    Southwest, England
    MS-Off Ver
    Office 2010
    Posts
    12

    Re: Struggling with COUNTIFS function returning 0 when value expected

    The line causing the problem is the line highlighted below:

    Please Login or Register  to view this content.

  15. #15
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Struggling with COUNTIFS function returning 0 when value expected

    Assuming the answer should be 4 then convert date to number.

    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    07-02-2014
    Location
    Southwest, England
    MS-Off Ver
    Office 2010
    Posts
    12

    Re: Struggling with COUNTIFS function returning 0 when value expected

    Thanks Andy, that seems to do it!! Can't believe it was that simple in the end! (Presumably CInt would also work for dates without times?)

    So how come it works in a worksheet comparing a date with a date but not in vba?

  17. #17
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Struggling with COUNTIFS function returning 0 when value expected

    CLNG and CINT will both strip off the time portion.

    probably due to VBAs use of US date format.

+ 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. CHOOSE Function not returning expected results.
    By khughes46 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-30-2014, 06:32 AM
  2. [SOLVED] Struggling with COUNTIFS formula - help!
    By Joey_997 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-03-2014, 10:54 AM
  3. [SOLVED] ISNUMBER function in formula not returning expected value
    By lukela85 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 11-09-2013, 05:12 PM
  4. [SOLVED] COUNTIFS Function returning wrong data
    By christopherw34 in forum Excel General
    Replies: 8
    Last Post: 05-02-2012, 12:29 PM
  5. LOOKUP function not returning expected value - Using vector_lookup format
    By JerichoForce in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-18-2006, 05:50 AM

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