I have a macro which copies a template worksheet, renames it, and then populates this new worksheet with data from another worksheet. The code is working, but it is creating this new worksheet in another workbook when I want this additional worksheet in the same workbook as all other activity in this macro. Here is the loop where the copy is done:
[vba] For Each wkSheet In ThisWorkbook.Sheets
If Left(wkSheet.Name, 2) = "D_" Then
ThisWorkbook.Worksheets(template.Name).Copy
Set newSheet = ActiveSheet
newSheet.Name = Right(wkSheet.Name, Len(wkSheet.Name) - 2)
Call InsData(newSheet, wkSheet)
End If
Next wkSheet [/vba]
I searched and could not find anything close... Any ideas about what I'm doing wrong? This is Office 2003.