Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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, |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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, |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thats great thanks,
One more question -- How about if the column L cell does not contain "RS" and is not blank "Bob Phillips" wrote: 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, |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|