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
What would the combined macro look like so that when I create a new sheet from the template using the first macro, it will link the new sheet to the master sheet using the second macro?
Thanks for any help!
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
What would the combined macro look like so that when I create a new sheet from the template using the first macro, it will link the new sheet to the master sheet using the second macro?
Thanks for any help!