Hello Everyone,
I new to VBA and was looking online on how to sum the values in the same row using VBA, i only found on the same column but nothing for the same row.
Cell C2 = 20, Cell D2 = 30, Cell E2 = 40 etc. More values can be added to to cell F2 and G2 etc.
I used the following code but is not working:
Sub Test()
Dim LastCell As Integer
Dim I As Long
LastCell = Range("C2").End(xlToRight).Column
For I = 2 To LastCell
Range("B13").Value = Excel.WorksheetFunction.Sum(Range("C2 & I"))
Next I
End Sub
Any help?
I new to VBA and was looking online on how to sum the values in the same row using VBA, i only found on the same column but nothing for the same row.
Cell C2 = 20, Cell D2 = 30, Cell E2 = 40 etc. More values can be added to to cell F2 and G2 etc.
I used the following code but is not working:
Sub Test()
Dim LastCell As Integer
Dim I As Long
LastCell = Range("C2").End(xlToRight).Column
For I = 2 To LastCell
Range("B13").Value = Excel.WorksheetFunction.Sum(Range("C2 & I"))
Next I
End Sub
Any help?