View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Lars-Åke Aspelin[_2_] Lars-Åke Aspelin[_2_] is offline
external usenet poster
 
Posts: 913
Default Worksheet number??

On Mon, 2 Feb 2009 13:23:02 -0800, John
wrote:

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 Befo=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 Befo=Sheets(n)

Hope this helps / Lars-Åke