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:
Any help?
Thanks
Brutium
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