Hi,
New to VBA so experiencing some serious teething problems with my lack of knowledge. I want to extract data based on 2 columns of a worksheet. Request type (Here Column E) and greater than date (Column d): Have hit a bit of wall on how to get around this in relation to the dates. Any help greatly appreciated. Rng2 seems to be causing the problem?????
Dim Requests(1 To 30)
Dim x As Long
Dim Rng1 As Range
Dim Rng2 As Range
Dim y As Long
Sub getrequest()
Worksheets("Sheet2").Activate
Entrydate = Range("C2")
Request = Range("C3")
Worksheets("NI").Select
Worksheets("NI").Activate
Worksheets("NI").Range("d1").AutoFilter
Worksheets("NI").Range("D1").AutoFilter Field:=4, Criteria1:=">" & Entrydate
Set Rng1 = Worksheets("NI").Range("E:E")
Set Rng2 = Worksheets("NI").Range("D:D")
y = Application.WorksheetFunction.SumProduct(Rng1 = Request, DateValue(Rng2) > Entrydate)
x = Application.WorksheetFunction.CountIf(Rng1, Request)
'output x
Worksheets("Sheet2").Select
Worksheets("Sheet2").Range("D3").Activate
i = 0
ActiveCell.Offset(i, 0) = x
ActiveCell.Offset(i, 1) = y
End Sub
New to VBA so experiencing some serious teething problems with my lack of knowledge. I want to extract data based on 2 columns of a worksheet. Request type (Here Column E) and greater than date (Column d): Have hit a bit of wall on how to get around this in relation to the dates. Any help greatly appreciated. Rng2 seems to be causing the problem?????
Dim Requests(1 To 30)
Dim x As Long
Dim Rng1 As Range
Dim Rng2 As Range
Dim y As Long
Sub getrequest()
Worksheets("Sheet2").Activate
Entrydate = Range("C2")
Request = Range("C3")
Worksheets("NI").Select
Worksheets("NI").Activate
Worksheets("NI").Range("d1").AutoFilter
Worksheets("NI").Range("D1").AutoFilter Field:=4, Criteria1:=">" & Entrydate
Set Rng1 = Worksheets("NI").Range("E:E")
Set Rng2 = Worksheets("NI").Range("D:D")
y = Application.WorksheetFunction.SumProduct(Rng1 = Request, DateValue(Rng2) > Entrydate)
x = Application.WorksheetFunction.CountIf(Rng1, Request)
'output x
Worksheets("Sheet2").Select
Worksheets("Sheet2").Range("D3").Activate
i = 0
ActiveCell.Offset(i, 0) = x
ActiveCell.Offset(i, 1) = y
End Sub