+ Reply to Thread
Results 1 to 6 of 6

Countifs code not working

  1. #1
    Forum Contributor
    Join Date
    07-23-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    211

    Countifs code not working

    Hi

    I have the following code to count the number of occurances that a date (DateCheck) occurs with a corresponding Depot name (Depot). This code is not picking up the two variables.

    Any advice why it is not working?

    Thanks

    Please Login or Register  to view this content.

  2. #2
    Forum Contributor
    Join Date
    07-23-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    211

    Re: Countifs code not working

    It must be something to do with dates (DateCheck) because when I checked with another stricg critera, it worked.

    Most puzzling!

    Thanks

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Countifs code not working

    Hi, newbi004,

    as you only supplied the code but no workbook/userForum and we donīt know what value txtWeekCommencing.Value is itīs hard to tell. I changed the UF.Textbox to a date and it worked fine for me, maybe you could use DateValue or DateSerial to get a "standard" date from the textbox:

    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Forum Contributor
    Join Date
    07-23-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    211

    Re: Countifs code not working

    Brilliant Holgar! Using DateValue did the trick.

    Thanks very much


  5. #5
    Forum Expert Debraj Roy's Avatar
    Join Date
    09-27-2012
    Location
    New Delhi,India
    MS-Off Ver
    Excel 2013
    Posts
    1,469

    Re: Countifs code not working

    One blind shot..

    Change this line..
    DateCheck = clng(txtWeekCommencing)
    Regards!
    =DEC2HEX(3563)

    If you like someone's answer, click the star to give them a reputation point for that answer...

  6. #6
    Forum Contributor
    Join Date
    07-23-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    211

    Re: Countifs code not working

    Thanks for your response, Debraj Roy.

    I tried clng before and it didn't work in my instance. The DateValue is the way forward.

    Thanks

+ 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. countifs not working with cell reference
    By Trig79 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-18-2013, 07:07 AM
  2. Replies: 0
    Last Post: 12-16-2011, 09:01 AM
  3. Countifs not working and namged range.
    By Lifeseeker in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-08-2011, 08:04 PM
  4. COUNTIFS not working
    By nosenga in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-13-2011, 04:38 AM
  5. COUNTIFS function not working
    By d_mack in forum Excel General
    Replies: 3
    Last Post: 08-26-2010, 02:25 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