I need a vba code to sum category 1 and sum category 2 separately and then add a line to the end of the row to sum both the totals. In all the cases, the number of rows and columns vary.
So there shouldn't be any coding specifying range. It can activesheet and activecell.
here are the two queries i have
1. I wrote a coding for the category 1, but it takes up ranges and also I have set active cell, so that it can tell where to write the sum formula.
2. I have done this for both the category, but when I make the total (category), adding the two activecells, don't turn up as formula.
Sub Find_Text_Sum_up_FillRight()
last = Cells(Rows.Count, "A").End(xlUp).Row
For i = last To 1 Step -1
If (Cells(i, "A").Value) Like "Sum (Category1)" Then
Cells(i, "C").Cells.Select
ActiveCell.FormulaR1C1 = "=SUM(R[-13]C:R[-1]C)"
Selection.Copy
Range(Selection, Selection.End(xlToRight)).Select
ActiveSheet.Paste
End If
Next i
Set myActiveCell1 = ActiveCell
End Sub
So there shouldn't be any coding specifying range. It can activesheet and activecell.
here are the two queries i have
1. I wrote a coding for the category 1, but it takes up ranges and also I have set active cell, so that it can tell where to write the sum formula.
2. I have done this for both the category, but when I make the total (category), adding the two activecells, don't turn up as formula.
Sub Find_Text_Sum_up_FillRight()
last = Cells(Rows.Count, "A").End(xlUp).Row
For i = last To 1 Step -1
If (Cells(i, "A").Value) Like "Sum (Category1)" Then
Cells(i, "C").Cells.Select
ActiveCell.FormulaR1C1 = "=SUM(R[-13]C:R[-1]C)"
Selection.Copy
Range(Selection, Selection.End(xlToRight)).Select
ActiveSheet.Paste
End If
Next i
Set myActiveCell1 = ActiveCell
End Sub