Can I use the SUM function to sum two or more columns in the same row?
Example:
Column : A B C D E
Total : 1 2 3 4 5
TotColAC: 4 6 (TotColBD)
Is it possible to use the SUM function or is there another way?
Thank you!
Can I use the SUM function to sum two or more columns in the same row?
Example:
Column : A B C D E
Total : 1 2 3 4 5
TotColAC: 4 6 (TotColBD)
Is it possible to use the SUM function or is there another way?
Thank you!
Using VBA. It will add cells from A1 to E1. You can modify as per your requirement.
Sub Add()
Dim totalAtoE As Double
totalAtoC = WorksheetFunction.Sum(Range("A1:E1"))
End Sub
only A1 and C1
Sub AddAandC()
Dim totalAandC As Double
totalAandC = WorksheetFunction.Sum(Range("A1"), Range("C1"))
End Sub
as per your comment
Sub Add()
Dim lastRow As Long, i As Integer, totalAtoC As Double, FinalSum As Double
lastRow = Range("A5000").End(xlUp).Row
For i = 1 To lastRow
totalAtoC = totalAtoC + WorksheetFunction.Sum(Range("A" & i & ":C" & i))
Next
FinalSum = totalAtoC
End Sub