Hi folks - I need to calculate the total of numbers entered into certain fields in a datagrid and paste that value into the final column of each row. I want to do this whenever the user advances to the next row.
I have also tried this in the KeyPress and RowColChange routines, and I get the same problem each time: the value is pasted into the final column of the NEXT row, rather than the current row.Code:Private Sub DataGrid1_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyDown Then Total = 0 For i = 3 To 10 If Len(DataGrid1.Columns(i).Text) > 0 Then Total = Total + Val(DataGrid1.Columns(i).Text) End If Next 'add total to Total column DataGrid1.Columns(14).Text = Total End Sub
Any help? Thanks, I need it!
Chao
Andrew




Reply With Quote