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.

PriyaV

New Member
Joined
Jul 1, 2021
Messages
5
Office Version
  1. 365
Platform
  1. Windows
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





1625152466133.png
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
13,575
Office Version
  1. 2007
Platform
  1. Windows
I'm glad to help you. Thanks for the feedback.
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Forum statistics

Threads
1,141,204
Messages
5,704,952
Members
421,372
Latest member
Jamie11

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top