Thread: Sum
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Sum

Try this code

Sub Test()
Dim iLastRow As Long
Dim i As Long

For i = 16 To 27
iLastRow = Cells(Rows.Count, i).End(xlUp).Row
If iLastRow = 1 And Cells(1, i).Value = "" Then
Else
Cells(iLastRow + 1, i).FormulaR1C1 = _
"=SUMIF(R1C12:R" & iLastRow & "C12,""RS"",R1C" & _
i & ":R" & iLastRow & "C" & i & ")"
End If
Next i

End Sub


--
HTH

Bob Phillips

"tjh" wrote in message
...
Hello,

Is there and easy way to total values using vba.

I have a spreadsheet with a few thousand rows and I would like VBA to go
through the worksheet, and for anything that has RS in column L -- I want

it
to take the value in columns P thru AA and sum them at the bottom and also
include the formula to the cell reference. A different total for each

column.

Thanks,