Hi im kind of limited with my vba but im keen to learn more, is there a smarter way or writing the below?
Code:
If dt_name = "M22" ThenwbDatatable.Worksheets(dt_name).Range("E2:E2").Value = "-"
For i = LBound(C, 1) To UBound(C, 1)
If C(i, 2) = Range("switch_State") Then
AGG1 = C(i, 5)
AGG2 = C(i, 6)
AGG3 = C(i, 7)
AGG4 = C(i, 8)
AGG5 = C(i, 9)
AGG6 = C(i, 10)
AGG7 = C(i, 11)
AGG8 = C(i, 12)
AGG9 = C(i, 13)
AGG10 = C(i, 14)
If AGG1 <> "|" Then
finalFormula = "(SUMIFS(DB!W:W,DB!$B:$B," & AGG1 & ",DB!W:W,1)-SUMIFS(DB!T:T,DB!$B:$B," & AGG1 & ",DB!T:T,1))/3"
If AGG2 <> "|" Then
finalFormula = AGG1 & "+" & "(SUMIFS(DB!W:W,DB!$B:$B," & AGG2 & ",DB!W:W,1)-SUMIFS(DB!T:T,DB!$B:$B," & AGG2 & ",DB!T:T,1))/3"
If AGG3 <> "|" Then
finalFormula = AGG2 & "+" & "(SUMIFS(DB!W:W,DB!$B:$B," & AGG3 & ",DB!W:W,1)-SUMIFS(DB!T:T,DB!$B:$B," & AGG3 & ",DB!T:T,1))/3"
End If
End If
End If
wbDatatable.Worksheets(dt_name).Range("F2:F2").Value = "-"
End If
Next
End If