How can I combine these two macros?

Status
Not open for further replies.

Milo2019

New Member
Joined
Apr 27, 2022
Messages
6
Office Version
  1. 365
Platform
  1. Windows
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!
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Duplicate to: Macro to copy existing sheet and linking cells of new sheet to master sheet

In future, please do not post the same question multiple times. Per Forum Rules (#12), posts of a duplicate nature will be locked or deleted.

In relation to your question here, I have closed this thread so please continue in the linked thread. If you do not receive a response, you can "bump" it by replying to it yourself, though we advise you to wait 24 hours before doing so, and not to bump a thread more than once a day.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,224,828
Messages
6,181,217
Members
453,024
Latest member
Wingit77

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