PDA

View Full Version : Nested If



maninjapan
10-07-2008, 10:59 PM
Im having a bit of trouble getting this to work, I believe the problem is with the first line....


If ComboBoxAccount.Text = "A1946" Or "A3448" Or "A3453" Then
If ComboBoxContract.Text = "FDAX" Then
Cells(NextRow, 6) = TextBoxPL.Text
Cells(NextRow, 7) = TextBoxPL.Text * Cells(NextRow, 5)
Cells(NextRow, 9) = (TextBoxLots.Text * TextBoxExchangeRate.Text) + (TextBoxLots.Text * 0.8)
ElseIf ComboBoxContract.Text = "FESX" Then
Cells(NextRow, 6) = TextBoxPL.Text
Cells(NextRow, 7) = TextBoxPL.Text * Cells(NextRow, 5)
Cells(NextRow, 9) = (TextBoxLots.Text * TextBoxExchangeRate.Text * 0.6) + (TextBoxLots.Text * 0.8)
ElseIf ComboBoxContract.Text = "Z" Then
Cells(NextRow, 6) = TextBoxPL.Text
Cells(NextRow, 7) = TextBoxPL.Text * Cells(NextRow, 5)
Cells(NextRow, 9) = (TextBoxLots.Text * TextBoxExchangeRate.Text * 0.56) + (TextBoxLots.Text * 0.8)
Else: Cells(NextRow, 7) = TextBoxPL.Text
Cells(NextRow, 9) = TextBoxLots.Text * (strCommission + 0.3)
End If
Else if......
End If
End If

georgiboy
10-07-2008, 11:14 PM
is "A1946" refering to a cell on a worksheet, if it is would it not be Sheet("Whatever").Range("A1946").Value or am i missing something.

maninjapan
10-07-2008, 11:16 PM
sorry, I can see how that would look like a cell. Actually its an account number. Im Trying to total and display Net P/Ls

GTO
10-07-2008, 11:16 PM
Each OR must seperate a test, like:

Sub Fake()
Dim i As Integer
i = 3

If i = 12 _
Or i = 13 _
Or i = 10 Then
MsgBox "Hi!", 0, ""
ElseIf i = 3 _
Or i = 4 _
Or i = 1 Then
MsgBox "Ho", 0, ""
Else
MsgBox "The gang is all here.", 0, ""
End If

End Sub

Also - kill the last 'End If'

Mark

maninjapan
10-07-2008, 11:18 PM
GTO, Right, that makes sense. Thanks a lot.