Hey everyone,

I need to find a value in a pivot table with a range of values over 12 months (Book5) when 3 criteria are met, Branch#, LOB# and Month#. Sum(if() works for the 1st month, but I do not know how to do the coding when the month changes.

Attached are copies of the two files I am working with and my coding so far.

```
Sub glvalueamount()
Dim glvalue As Integer
Dim glperiod As String
If (glperiod = "01") Then
glvalue = Selection.FormulaArray = "=SUM(IF([Book5]Sheet1!R6C1:R34C1=RC[-4],IF([Book5]Sheet1!R6C2:R34C2=RC[-3],IF([Book5]Sheet1!R4C3=RC[-5],[Book5]Sheet1!R6C7:R34C7,0),0)))"
Else
If (glperiod = "02") Then
glvalue = Selection.FormulaArray = "=SUM(IF([Book5]Sheet1!R6C1:R34C1=RC[-4],IF([Book5]Sheet1!R6C2:R34C2=RC[-3],IF([Book5]Sheet1!R4C3=RC[-5],[Book5]Sheet1!R6C7:R34C7,0),0)))"
If (glperiod = "03") Then
glvalue = Selection.FormulaArray = "=SUM(IF([Book5]Sheet1!R6C1:R34C1=RC[-4],IF([Book5]Sheet1!R6C2:R34C2=RC[-3],IF([Book5]Sheet1!R4C3=RC[-5],[Book5]Sheet1!R6C7:R34C7,0),0)))"
If (glperiod = "04") Then
glvalue = Selection.FormulaArray = "=SUM(IF([Book5]Sheet1!R6C1:R34C1=RC[-4],IF([Book5]Sheet1!R6C2:R34C2=RC[-3],IF([Book5]Sheet1!R4C3=RC[-5],[Book5]Sheet1!R6C7:R34C7,0),0)))"
If (glperiod = "05") Then
glvalue = Selection.FormulaArray = "=SUM(IF([Book5]Sheet1!R6C1:R34C1=RC[-4],IF([Book5]Sheet1!R6C2:R34C2=RC[-3],IF([Book5]Sheet1!R4C3=RC[-5],[Book5]Sheet1!R6C7:R34C7,0),0)))"
If (glperiod = "06") Then
glvalue = Selection.FormulaArray = "=SUM(IF([Book5]Sheet1!R6C1:R34C1=RC[-4],IF([Book5]Sheet1!R6C2:R34C2=RC[-3],IF([Book5]Sheet1!R4C3=RC[-5],[Book5]Sheet1!R6C7:R34C7,0),0)))"
If (glperiod = "07") Then
glvalue = Selection.FormulaArray = "=SUM(IF([Book5]Sheet1!R6C1:R34C1=RC[-4],IF([Book5]Sheet1!R6C2:R34C2=RC[-3],IF([Book5]Sheet1!R4C3=RC[-5],[Book5]Sheet1!R6C7:R34C7,0),0)))"
If (glperiod = "08") Then
glvalue = Selection.FormulaArray = "=SUM(IF([Book5]Sheet1!R6C1:R34C1=RC[-4],IF([Book5]Sheet1!R6C2:R34C2=RC[-3],IF([Book5]Sheet1!R4C3=RC[-5],[Book5]Sheet1!R6C7:R34C7,0),0)))"
If (glperiod = "09") Then
glvalue = Selection.FormulaArray = "=SUM(IF([Book5]Sheet1!R6C1:R34C1=RC[-4],IF([Book5]Sheet1!R6C2:R34C2=RC[-3],IF([Book5]Sheet1!R4C3=RC[-5],[Book5]Sheet1!R6C7:R34C7,0),0)))"
If (glperiod = "10") Then
glvalue = Selection.FormulaArray = "=SUM(IF([Book5]Sheet1!R6C1:R34C1=RC[-4],IF([Book5]Sheet1!R6C2:R34C2=RC[-3],IF([Book5]Sheet1!R4C3=RC[-5],[Book5]Sheet1!R6C7:R34C7,0),0)))"
If (glperiod = "11") Then
glvalue = Selection.FormulaArray = "=SUM(IF([Book5]Sheet1!R6C1:R34C1=RC[-4],IF([Book5]Sheet1!R6C2:R34C2=RC[-3],IF([Book5]Sheet1!R4C3=RC[-5],[Book5]Sheet1!R6C7:R34C7,0),0)))"
If (glperiod = "12") Then
glvalue = Selection.FormulaArray = "=SUM(IF([Book5]Sheet1!R6C1:R34C1=RC[-4],IF([Book5]Sheet1!R6C2:R34C2=RC[-3],IF([Book5]Sheet1!R4C3=RC[-5],[Book5]Sheet1!R6C7:R34C7,0),0)))"
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End Sub
```

Display More

Has anyone ever dealt with a similar challenge?

Thank you.