JenniferMurphy
Well-known Member
- Joined
- Jul 23, 2011
- Messages
- 2,525
- Office Version
- 365
- Platform
- Windows
Could someone post the code needed to add up the columns in an array passed as an argument to a Sub and put the sums in the row just below it?
I got this far and I put it in a code module in the calling workbook.
But I can't test it because the name does not come up when I open up the Macros dialog in the Developer tab.
I got this far and I put it in a code module in the calling workbook.
VBA Code:
Sub ColumnSum(pTable As Range)
Dim Sums() As Double
Dim row As Integer
Dim col As Integer
Dim rows As Integer
Dim cols As Integer
rows = UBound(pTable, 1)
cols = UBound(pTable, 2)
ReDim Sums(cols)
For row = 0 To rows
For col = 0 To cols
Sums(col) = Sum(cols) + pTable(row, col)
Next col
Next row
'How to store the results in row+1?
End Sub
But I can't test it because the name does not come up when I open up the Macros dialog in the Developer tab.