Worksheet number??
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. |
Worksheet number??
One way:
Befo=ActiveSheet.Index In article , 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. |
Worksheet number??
Try it this way...
Sheets(ProjectSummaryTemplateSheetName).Copy Befo=ActiveSheet -- Rick (MVP - Excel) "John" wrote in message ... 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. |
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 |
All times are GMT +1. The time now is 06:36 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com