Re: SUMIFS in VBA Help needed please
Domenic, Joe4, to give you a bit of background, here is my full code;
Dim oldAddress As String
Dim oldValue As String
---------------------------------------------------
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
On Error GoTo err
Dim sSheetName As String, dblMyVal As Double
sSheetName = "Main"
If ActiveSheet.name = "Main" Then
Application.EnableEvents = False
Sheets("Tracking").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Value = Range("A" & Target.Row).Value
Sheets("Tracking").Range("A" & Rows.Count).End(xlUp).Offset(0, 1).Value = Range("B" & Target.Row).Value
Sheets("Tracking").Range("A" & Rows.Count).End(xlUp).Offset(0, 2).Value = Range("C" & Target.Row).Value
Sheets("Tracking").Range("A" & Rows.Count).End(xlUp).Offset(0, 3).Value = Range("D" & Target.Row).Value
Sheets("Tracking").Range("A" & Rows.Count).End(xlUp).Offset(0, 4).Value = Cells(2, Target.Column).Value
Sheets("Tracking").Range("A" & Rows.Count).End(xlUp).Offset(0, 5).Value = oldValue
Sheets("Tracking").Range("A" & Rows.Count).End(xlUp).Offset(0, 6).Value = Target.Value
Sheets("Tracking").Range("A" & Rows.Count).End(xlUp).Offset(0, 7).Value = Target.Value - oldValue
rw = Sheets("Tracking").Range("A" & Rows.Count).End(xlUp).Row
dblMyVal = Evaluate("SumProduct(($H:$H)*($A:$A=A" & rw & ")*($B:$B=B" & rw & ")*($D:$D=D" & rw & ")*(Month($E:$E=E" & rw & ")=Month(E" & rw & "))*(Year($E:$E)=Year(E" & rw & ")))")
Sheets("Tracking").Range("A" & Rows.Count).End(xlUp).Offset(0, 8).Value = dblMyVal
Sheets("Tracking").Hyperlinks.Add anchor:=Sheets("Tracking").Range("A" & Rows.Count).End(xlUp).Offset(0, 9), Address:="", SubAddress:="'" & sSheetName & "'!" & oldAddress, TextToDisplay:=oldAddress
End If
err:
Application.EnableEvents = True
End Sub
---------------------------------------------------
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
On Error GoTo err
oldValue = Target.Value
oldAddress = Target.Address
err:
End Sub