VBA - update formula when creating a new sheet

ellisa21

New Member
Joined
Jul 29, 2020
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have several sheet here
1596023381059.png

- Total is the calculation of all sheets (exclude Template)
- Template is the master sheet of Nancy, Quincy, Bella, etc

Step on macro :
1. Add new sheet
2. Copy and paste 'Template' sheet
3. Calculate the total on 'Total' sheet (sum formula)

The problem is when I run the second time, the total calculation of last new sheet doesn't include in the calculation.
eg:
1. Run the macro and create a new sheet 'testcopy'
3. Run the macro again
4. Macro create a new sheet 'copy' but the formula doesn't include 'testcopy'

My question : how can I update the formula?


VBA Code:
'   Start calculation
    Range("L6").Select
    Application.CutCopyMode = False
    ActiveCell.FormulaR1C1 = "=Quincy!RC+Nancy!RC+Bella!RC+Abel!RC+Copy!RC"
    Range("L6").Select
    Selection.AutoFill Destination:=Range("L6:L21"), Type:=xlFillDefault
    Range("L6:L21").Select
    Selection.AutoFill Destination:=Range("C6:L21"), Type:=xlFillDefault
    Range("C6:L21").Select
    ActiveWindow.SmallScroll Down:=3
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Forum statistics

Threads
1,214,383
Messages
6,119,196
Members
448,874
Latest member
Lancelots

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
Back
Top