dirtyrat00
11-06-2014, 01:59 PM
Below is my code showing if SumXj equals 1 then do the listed tasks. When I step into each line, the output shows SumXj reaches 1 around the 9th iteration. Instead of doing the listed tasks under SumXj =1, it skips over the tasks and into the following ElseIf, looping again. Can someone explain why this is happening? Thank you
If Sum1 > 1 And Sum2 > 1 Then 'Two-Phase Region
SumXj = 0
For g = 0.01 To 1 Step 0.01
For i = 1 To n
LiqX = (Z(i) / (1 + Sng(g) * (K(i) - 1)))
SumXj = SumXj + LiqX
Cells(i + 7, 13).Value = SumXj
If SumXj = 1 Then
Sng = Sng(i)
SnL = 1 - Sng(i)
ElseIf SumXj < 1 Then
End If
Next i
Next g
If Sum1 > 1 And Sum2 > 1 Then 'Two-Phase Region
SumXj = 0
For g = 0.01 To 1 Step 0.01
For i = 1 To n
LiqX = (Z(i) / (1 + Sng(g) * (K(i) - 1)))
SumXj = SumXj + LiqX
Cells(i + 7, 13).Value = SumXj
If SumXj = 1 Then
Sng = Sng(i)
SnL = 1 - Sng(i)
ElseIf SumXj < 1 Then
End If
Next i
Next g