Home Count columns based on date range
Reply: 0

Count columns based on date range

user4912 Published in September 19, 2018, 6:43 pm

I'm new to VBA. I'm trying to accomplish the below thing in VBA and not sure how to do this.

  1. In Column "K" in sheet "Latency" i have dates in the form of "11/10/2016 16:17". (there will be multiple dates in the column)
  2. In column "O" I have few vales in a cell "Pass" or Fail"

What I want to do is, when the script is run, it should first throw up a dialogue box asking the user to enter the date range. Once the user gives the date range, it should select that columns and look out for "Pass" in "o" column and count the value and update it in a particular cell.

I have tried the below code, but I'm not sure how to add the count value using the date range criteria:

Sub WBR()
Dim s As String
Dim r As Range
Dim wf As WorksheetFunction
Dim xlSheet As Worksheet
Set xlSheet = ActiveWorkbook.Worksheets("Latency") 'sets the worksheet
Set wf = Application.WorksheetFunction
Set r = xlSheet.Range("O:O")                       'sets the range to search
s = "Pass"
[AE4] = wf.CountIf(r, s)
s = "Fail"
[AE5] = wf.CountIf(r, s)

With ActiveWorkbook.Worksheets("TT")
    [AE119] = wf.CountIfs(.Range("G:G"), "Yes", _
                          .Range("K:K"), "Tablet")
 End With

With ActiveWorkbook.Worksheets("TT")                'no of tickets processed
    [AE119] = wf.CountIfs(.Range("G:G"), "Yes", _
                          .Range("I:I"), "<>Duplicate TT", _
                          .Range("K:K"), "Tablet")
End With

End Sub

share|improve this question

1 Answer 1

active oldest votes
up vote 0 down vote accepted
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.32955 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO