This is the Macro I have to create a new sheet from my template (labeled as COQ 001) which works:
Sub CreateSheet()
Dim xName As String
Dim xSht As Object
Dim xNWS As Worksheet
On Error Resume Next
xName = InputBox("Please enter COQ Numeber. For Example: COQ 00X", "NEW QOQ")
If xName = "COQ 001" Then Exit Sub
Set xSht = Sheets(xName)
If Not xSht Is Nothing Then
MsgBox "Sheet cannot be created as there is already a worksheet with the same name in this workbook"
Exit Sub
End If
Sheets("COQ 001").Copy after:=Sheets(Sheets.Count)
Set xNWS = Sheets(Sheets.Count)
xNWS.Name = xName
End Sub
This is the macro I have to link the template sheet (COQ 001) to the master sheet which also works:
Sub Link2Log()
'
' Link2Log Macro
'
'
Rows("10:10").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Range("B10").Select
ActiveCell.FormulaR1C1 = "='COQ 002'!R[-3]C[5]"
Range("C10").Select
ActiveCell.FormulaR1C1 = "='COQ 002'!R[2]C:R[2]C[5]"
Range("D10").Select
ActiveCell.FormulaR1C1 = "='COQ 002'!R[-2]C[3]"
Range("E10").Select
ActiveCell.FormulaR1C1 = "='COQ 002'!R[-1]C[2]"
Range("G10").Select
ActiveCell.FormulaR1C1 = "='COQ 002'!R[40]C"
Range("G11").Select
End Sub
Question: How do I combine the two macros above into one, so that every time I create a new COQ sheet copied off the template, it will link the cells to the master sheet? I want it to add a row when I create a new sheet and each time link the cells to the master sheet. I don't know what to place in the above location to have it grab the newly created sheet and link it in leu of COQ 002 or the template sheet everytime , nor how to combine the two macros above. Please help, Thanks,
Sub CreateSheet()
Dim xName As String
Dim xSht As Object
Dim xNWS As Worksheet
On Error Resume Next
xName = InputBox("Please enter COQ Numeber. For Example: COQ 00X", "NEW QOQ")
If xName = "COQ 001" Then Exit Sub
Set xSht = Sheets(xName)
If Not xSht Is Nothing Then
MsgBox "Sheet cannot be created as there is already a worksheet with the same name in this workbook"
Exit Sub
End If
Sheets("COQ 001").Copy after:=Sheets(Sheets.Count)
Set xNWS = Sheets(Sheets.Count)
xNWS.Name = xName
End Sub
This is the macro I have to link the template sheet (COQ 001) to the master sheet which also works:
Sub Link2Log()
'
' Link2Log Macro
'
'
Rows("10:10").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Range("B10").Select
ActiveCell.FormulaR1C1 = "='COQ 002'!R[-3]C[5]"
Range("C10").Select
ActiveCell.FormulaR1C1 = "='COQ 002'!R[2]C:R[2]C[5]"
Range("D10").Select
ActiveCell.FormulaR1C1 = "='COQ 002'!R[-2]C[3]"
Range("E10").Select
ActiveCell.FormulaR1C1 = "='COQ 002'!R[-1]C[2]"
Range("G10").Select
ActiveCell.FormulaR1C1 = "='COQ 002'!R[40]C"
Range("G11").Select
End Sub
Question: How do I combine the two macros above into one, so that every time I create a new COQ sheet copied off the template, it will link the cells to the master sheet? I want it to add a row when I create a new sheet and each time link the cells to the master sheet. I don't know what to place in the above location to have it grab the newly created sheet and link it in leu of COQ 002 or the template sheet everytime , nor how to combine the two macros above. Please help, Thanks,