I want to sum the contents of 4 columns (column U, V, W, X) into a sub-total in column Y. I have attempted to use the following code but it does not work. The columns will always contain numeric data or be completely empty so I have probably tried to include some elements that are not necessary.
Any help would be fantastic.
Any help would be fantastic.
VBA Code:
Private Sub calculateTotalTradeScore()
Dim sourceSheet As Worksheet 'Source Sheet'
Dim rw As Range
Dim col As Range
'Dim quantity As Integer 'variable to store current quantity'
'quantity = convertToInt(Cells(row.row, 5).Value)
Dim PrepScore As Integer 'Preparation score'
Dim EntryScore As Integer 'Entry score'
Dim STOPScore As Integer 'STOP score'
Dim TradeExeScore As Integer 'Trade Execution score'
For Each rw In sourceSheet.UsedRange.Rows 'Looping on each row of Sheet1'
If rw.row <> 1 Then 'Skip first header row'
Dim TotalTradeScore As Double 'Calculated Total Trade score
PrepScore = convertToInt(Cells(rw.row, 22).Value)
EntryScore = convertToInt(Cells(rw.row, 23).Value)
STOPScore = convertToInt(Cells(rw.row, 24).Value)
TradeExeScore = convertToInt(Cells(rw.row, 25).Value)
TotalTradeScore = PrepScore + EntryScore + STOPScore + TradeExeScore
Source.Cells(rw.row, 26).Value = TotalTradeScore 'applies Total trade score'
End If 'Check if not First Row'
Next rw
Exit Sub
End Sub