Assign formula to summary sheet

Brutium

Board Regular
Joined
Mar 27, 2009
Messages
188
Hello Everyone,

I have a macro which creates from a template (my MasterSheet), a number of sheets, which are based on a sheet called Tools. The data coming from these sheets is then supposed to transfer over onto a summary sheet(which I called Class). My problem is that with the macro that I have, only one line of data is copied over to the summary sheet. I need to have all the rows in my Class sheet, to be filled with the data from my new sheets. I understand that my summary sheet cannot refer to inexistant sheets, since they have not yet been created. My question is then, what do I need to do to make sure my data transfer over? How do I assign the same formula to all the rows. (at the moment only row 9 starting at C9 gets filled I need to go down to row 52 starting at C52.

The following is my macro:

Sub Addsheets()
Dim LR As Long, i As Long, MasterSheet As Long
Dim rngTopOfList As Range
Dim wsName As String
Dim n As Integer

n = 0
With Sheets("tools")

Set rngTopOfList = .Range("B3")

LR = .Cells(.Rows.Count, rngTopOfList.Column).End(xlUp).Row

MasterSheet = ActiveWorkbook.Sheets.Count

If LR > rngTopOfList.Row Then

For i = 0 To LR - rngTopOfList.Row
ActiveWorkbook.Sheets(MasterSheet).Copy _
after:=Worksheets(MasterSheet + i - 1)
ActiveWorkbook.Sheets(MasterSheet + i).Name = _
rngTopOfList.Offset(i).Value '''Can be replaced with wsName if the following line is moved before.

''' Here begins changes
wsName = rngTopOfList.Offset(i).Value

ActiveWorkbook.Sheets("Class").Range("C9").Offset(0, n).Value = _
"=" & wsName & "!M9"
n = n + 1
'''
Next i

End If

ActiveWorkbook.Sheets(MasterSheet).Name = rngTopOfList.Value
Worksheets("MasterSheet").Visible = xlSheetVeryHidden
End With
Set rngTopOfList = Nothing
End Sub

Any help?

Thanks

Brutium
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,224,595
Messages
6,179,798
Members
452,943
Latest member
Newbie4296

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