maninjapan
10-02-2008, 10:54 PM
Im trying the following code, but getting an error on the Else.....
Says there is no If for it......
Private Sub CommandNextContract_Click()
' Ensure all data is entered
If ComboBoxTrader.Text = "" Or _
ComboBoxContract.Text = "" Or _
ComboBoxmonth.Text = "" Or _
TextBoxLots.Text = "" Or _
TextBoxPL.Text = "" Or _
ComboBoxCurrency.Text = "" Or _
TextBoxExchangeRate.Text = "" Then _
MsgBox "Enter Data!", vbInformation, "Error Message"
TextBoxDate.SetFocus
Exit Sub
Else
' Make sure Sheet1 is active
Sheets("Sheet1").Activate
' Determine the next empty row
NextRow = _
Application.WorksheetFunction.CountA(Range("A:A")) + 1
' Transfer the Date,Trader,Contract,Month,Lots,P&L,Currency
Cells(NextRow, 1) = TextBoxDate.Text
Cells(NextRow, 2) = ComboBoxTrader.Text
Cells(NextRow, 3) = ComboBoxContract.Text
Cells(NextRow, 4) = ComboBoxmonth.Text
Cells(NextRow, 5) = TextBoxLots.Text
Cells(NextRow, 6) = TextBoxPL.Text
Cells(NextRow, 7) = ComboBoxCurrency.Text
' Clear Trade Info for next entry
ComboBoxContract.Text = ""
ComboBoxmonth.Text = ""
TextBoxLots.Text = ""
TextBoxPL.Text = ""
ComboBoxCurrency.Text = "USD"
TextBoxExchangeRate.Text = "1"
ComboBoxContract.SetFocus
End If
End Sub
Says there is no If for it......
Private Sub CommandNextContract_Click()
' Ensure all data is entered
If ComboBoxTrader.Text = "" Or _
ComboBoxContract.Text = "" Or _
ComboBoxmonth.Text = "" Or _
TextBoxLots.Text = "" Or _
TextBoxPL.Text = "" Or _
ComboBoxCurrency.Text = "" Or _
TextBoxExchangeRate.Text = "" Then _
MsgBox "Enter Data!", vbInformation, "Error Message"
TextBoxDate.SetFocus
Exit Sub
Else
' Make sure Sheet1 is active
Sheets("Sheet1").Activate
' Determine the next empty row
NextRow = _
Application.WorksheetFunction.CountA(Range("A:A")) + 1
' Transfer the Date,Trader,Contract,Month,Lots,P&L,Currency
Cells(NextRow, 1) = TextBoxDate.Text
Cells(NextRow, 2) = ComboBoxTrader.Text
Cells(NextRow, 3) = ComboBoxContract.Text
Cells(NextRow, 4) = ComboBoxmonth.Text
Cells(NextRow, 5) = TextBoxLots.Text
Cells(NextRow, 6) = TextBoxPL.Text
Cells(NextRow, 7) = ComboBoxCurrency.Text
' Clear Trade Info for next entry
ComboBoxContract.Text = ""
ComboBoxmonth.Text = ""
TextBoxLots.Text = ""
TextBoxPL.Text = ""
ComboBoxCurrency.Text = "USD"
TextBoxExchangeRate.Text = "1"
ComboBoxContract.SetFocus
End If
End Sub