My current code creates 9 copies of a sheet called "MasterCalculator". It decides the amount of copies to be named by counting the number of cells filled in Row 1 (starting at column C) in the other sheet Called 'LLP Disc Sheet'. Each of the 9 sheets created are then named. Sheet 1's name comes from C1 in the 'LLP Disc Sheet', Sheet 2's name comes from D1 in the 'LLP Disc Sheet', Sheet 3's names comes from E1 in the 'LLP Disc Sheet', and so on.
Option Explicit
Public Sub NewSheets()
Dim shCol As Integer
Dim i As Integer
Dim ws As Worksheet
Dim sh As Worksheet
Set ws = Sheets("MasterCalculator")
Set sh = Sheets("LLP Disc Sheet")
Application.ScreenUpdating = 0
Application.EnableEvents = 0
shCol = 2
sh.Activate
For i = 2 To sh.Range("A1:Z1").Cells.SpecialCells(xlCellTypeConstants).Count
shCol = shCol + 1
Application.StatusBar = "Processing " & sh.Cells(1, shCol).Text & Format(i / sh.Range("A1:Z1").Cells.SpecialCells(xlCellTypeConstants).Count, " #0.0 %")
Select Case shCol
Case Is = 3
ws.Copy After:=sh
Case Else
ws.Copy After:=Sheets(sh.Cells(1, shCol - 1).Text)
End Select
ActiveSheet.Name = sh.Cells(1, shCol).Text
Application.CutCopyMode = False
Next i
sh.Activate
Application.StatusBar = 0
Application.EnableEvents = 1
Application.ScreenUpdating = 1
Application.CalculateFull
End Sub
So now that all the sheets are created and named... I now want to update the formulas in each since they're copies of the sheet called 'MasterCalculator'. There are 2 cells in each sheet I need to update - cell B1 and cell M4. Cell B1 contains the formula "=+'LLP Disc Sheet'!C1". The sheet that was created based on C1 in the 'LLP Disc Sheet' can keep this formula. However, the next sheet (sheet 2) that was created and named based off of D1 in the "LLP Disc Sheet" needs to be updated to "=+'LLP Disc Sheet'!D1". This goes on with the rest of the sheets. The next has to change to =+'LLP Disc Sheet'!E1 and so on. How do I create a code to replace that cell in each of the newly created sheet with an updated formula that only changes it to cell referenced one cell after in the 'LLP Disc Sheet'?
ActiveSheet.Range(“B1:M4”).Replace_
What: ="LLP Disc Sheet'!C1", Replacement:="LLP Disc Sheet'!D1”,_ ‘but I want it to continue to the next sheet to replace D1 with E1 and so on until all of the B1 cells match their sheet names (it also allow all the data to be filled in). All of these will be found in cell B1 in the MasterCalculator copies
What: ="LLP Disc Sheet'!$C$1:$C$", Replacement:=" LLP Disc Sheet'!$D$1:$D$”,_ ‘but I want it to continue to the next sheet to replace $D$1 with E$1$ and $D$ with $E$ and so on until all of the M4 cells are set to 0.
SearchOrder:=xlByRows, MatchCase:=True
=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,255)
. Enter it in B1 and M4 (assuming it is the same as B1). You wont have to change the formula for each new sheet. Formula will work once the file is saved. – Naresh