Worksheet number??

  • Thread starter Thread starter John
  • Start date Start date
J

John

What code do I execute to find the Worksheet number associated with the
currently selected worksheet? I have a macro that creates a new worksheet
before sheet1 by copying a template sheet using:
Sheets(ProjectSummaryTemplateSheetName).Copy Before:=Sheets(1)
I'd like to place it right before the selected worksheet.
 
Try it this way...

Sheets(ProjectSummaryTemplateSheetName).Copy Before:=ActiveSheet
 
What code do I execute to find the Worksheet number associated with the
currently selected worksheet? I have a macro that creates a new worksheet
before sheet1 by copying a template sheet using:
Sheets(ProjectSummaryTemplateSheetName).Copy Before:=Sheets(1)
I'd like to place it right before the selected worksheet.

Try this code:

For i = 1 To Worksheets.Count
If Worksheets(i).Name = ActiveSheet.Name Then n = i
Next i
Sheets(ProjectSummaryTemplateSheetName).Copy Before:=Sheets(n)

Hope this helps / Lars-Åke
 
Back
Top