Originally Posted by
aerodoc
The following function will not update when I change the cells with the name reference "e_allow_1" and the offsets shown below. The function does not call them directly. Would I need to put them in as function variables? (i.e. Function max(mat,e1,e1t_1,e1c_1,e2t_1,e2c_1,e6s)? This would really be a mess though.
Function max(mat, e1)
e1t_1 = Range("e_allow_1").Offset(0, 0).Value
e1c_1 = Range("e_allow_1").Offset(1, 0).Value
e2t_1 = Range("e_allow_1").Offset(2, 0).Value
e2c_1 = Range("e_allow_1").Offset(3, 0).Value
e6s_1 = Range("e_allow_1").Offset(4, 0).Value
If mat = 1 And (e1 > 0) Then
max = e1t_1 / e1 - 1
ElseIf mat = 1 And (e1 = 0) Then
max = 999
ElseIf mat = 1 And (e1 < 0) Then
max = e1c_1 / e1 - 1
ElseIf mat = 2 And (e1 > 0) Then
max = e1t_2 / e1 - 1
ElseIf mat = 2 And (e1 = 0) Then
max = 999
ElseIf mat = 2 And (e1 < 0) Then
max = e1c_2 / e1 - 1
ElseIf mat = 3 And (e1 > 0) Then
max = e1t_3 / e1 - 1
ElseIf mat = 3 And (e1 = 0) Then
max = 999
ElseIf mat = 3 And (e1 < 0) Then
max = e1c_3 / e1 - 1
Else
max = " "
End If
End Function