maninjapan
09-16-2008, 04:40 AM
After posting a number of rows of data to the spreadsheet through CommandNextContract_Click I would like to subtotal the data. What would a command look like to total all data since the last total....(the number of rows to subtotal will vary each time,)
This is what I have so far
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 = "" 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"
ComboBoxContract.SetFocus
End If
End Sub
This is what I have so far
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 = "" 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"
ComboBoxContract.SetFocus
End If
End Sub