Sub Summarize()
Dim lastRow&, filterCriteria$
filterCriteria = "<=01/10/2014"
With Sheets(1)
lastRow = .Cells(.Rows.Count, 2).End(xlUp).Row
ActiveWorkbook.Names.Add Name:="probe", RefersToR1C1:="=" & .Name & "!R2C2:R" & lastRow & "C2"
End With
With Sheets(2)
Range("probe").AdvancedFilter xlFilterCopy, , .Range("A3"), True
.Range("B4:B10").Value = "=SUMIFS(" & Sheets(1).Name & "!$D$3:D" & lastRow & "," & Sheets(1).Name & "!$C$3:C" & lastRow & "," & Chr(34) & filterCriteria & Chr(34) & "," & Sheets(1).Name & "!$B$3:B" & lastRow & "," & Sheets(2).Range("A4").Address(0, 0) & ")"
.[B3] = "Quantity"
End With
End Sub
ThisWorkbook.Names.Add Name:="probe", RefersToR1C1:="=" & .Name & "!R2C2:R" & lastRow & "C2"
ThisWorkbook.Names.Add Name:="probe", RefersToR1C1:="='" & .Name & "'!R2C2:R" & lastRow & "C2"
Range("probe").AdvancedFilter xlFilterCopy, , .Range("A3"), True
Sub Summarize()
Dim lastRow&, filterCriteria$
filterCriteria = "<=01/14/2014"
With Sheets(1)
lastRow = .Cells(.Rows.Count, 2).End(xlUp).Row
ThisWorkbook.Names.Add Name:="probe", RefersToR1C1:="=" & "'" & .Name & "'!R2C2:R" & lastRow & "C2"
End With
With Sheets(2)
Range("probe").AdvancedFilter xlFilterCopy, , .Range("A3"), True
.Range("B4:B10").Value = "=SUMIFS('" & Sheets(1).Name & "'!$D$3:D" & lastRow & ",'" & Sheets(1).Name & "'!$C$3:C" & lastRow & "," & Chr(34) & filterCriteria & Chr(34) & ",'" & Sheets(1).Name & "'!$B$3:B" & lastRow & "," & Sheets(2).Range("A4").Address(0, 0) & ")"
.[B3] = "Quantity"
End With
End Sub