Hello.. Hope all are doing well.
I'm trying create multiple copy of a Template tab/sheet based on the table on Index tab. On Index tab i have a table Emp_ID (col A), Emp_name (col B) and Tab_name (Col C). The macro will create a copy of Template tab, set the tab name as Index col C tab name and take Emp_Id and Emp name and put it on E2 and E3 of new tab. The below macro is working fine.
Sub CreateTab()
Dim r As Range
For Each r In Sheets("Index").Range("C2:C5")
If r.Value <> "" Then
Sheets("Template").Copy after:=Worksheets(Worksheets.Count)
ActiveSheet.Name = r.Value
Range("E2").Select
ActiveCell.FormulaR1C1 = r.Offset(0, -2).Value
Range("E3").Select
ActiveCell.FormulaR1C1 = r.Offset(0, -1).Value
End If
Next
End Sub
Now i want to put a process to avoid creating duplicated tab. Means if i add more entry to Index table and run the macro then it will copy Template and create tab for the new entries only. For existing entries where a tab is already exist, it should not create duplicate tab. how do i do it?
Bookmarks