Announcement

Collapse
No announcement yet.

Countif And Dates In Vba

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Countif And Dates In Vba



    I need a little help with countif and dates in vba. I have a spreadsheet that has different dates in column 3. I need to count the number of times a specific date appears in this column using vba. I'm thinking countif should work, but I can't get it to count the dates.

  • #2
    Re: Countif And Dates In Vba

    Code:
    ActiveCell.FormulaR1C1 = "=COUNTIF(R[-2]C[2]:R[2]C[2],DATE(2007,1,1))"
    The formula is read as =COUNTIF("Range",DATE(Year,Month,Day))

    Comment


    • #3
      Re: Countif And Dates In Vba

      I would like to hold the value as a variable in vba:

      Code:
      lastrow=worksheetfunction.countif(columns(3),DATE VALUE HERE!)
      but I cannot get it to return a value.

      Comment


      • #4
        Re: Countif And Dates In Vba

        Can you post an example? I don't quite get what you are trying to accomplish now.

        Comment


        • #5
          Re: Countif And Dates In Vba

          See attached. I need a variable to store how many times the date 3/15/2007 is listed in column 1.
          Attached Files

          Comment


          • #6
            Re: Countif And Dates In Vba

            I guess I just don't get the problem your having. Can't you just put somewhere...

            =COUNTIF(A:A,DATE(2007,3,15))

            Comment


            • #7


              Re: Countif And Dates In Vba

              Or in VBA:
              Code:
              rngLastRow = Application.CountIf(Range("A:A"), DateValue("3/15/2007"))
              ' or
              rngLastRow = Application.CountIf(Columns(1), DateValue("3/15/2007")
              ' or
              rngLastRow = Application.CountIf(Columns(1), DateSerial(2007,3,15)
              Last edited by shg; April 20th, 2007, 03:03.
              Entia non sunt multiplicanda sine necessitate.

              Comment

              Working...
              X