Formula to be inserted on all sheets from a certain sheet onwards

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,561
Office Version
  1. 2021
Platform
  1. Windows
I have the following formula that must be inserted on all sheets from BR1 Sales

If I am on sheet BR1 Sales , the formula in only inserted on this sheet , but not on the sheets after this

It would be appreciated if someone could kindly amend my formula

Code:
 Sub Formula_Balance()
Dim I As Long, LR As Long

For I = Sheets("BR1 Sales").Index To Worksheets.Count
LR = Cells(Rows.Count, "A").End(xlUp).Row
Range("H1").Value = "Balance"
Range("H2:H" & LR).FormulaR1C1 = "=RC[-2]-RC[-1]"


Next I
End Sub
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
I have managed to resolve this

Code:
 Sub Formula_Balance()
Dim I As Long, LR As Long

For I = Sheets("BR1 Sales").Index To Worksheets.Count
With Worksheets(I)

LR = .Cells(.Rows.Count, "A").End(xlUp).Row
.Range("H1").Value = "Balance"
.Range("H2:H" & LR).FormulaR1C1 = "=RC[-2]-RC[-1]"
End With


Next I
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,611
Messages
6,120,513
Members
448,967
Latest member
screechyboy79

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