Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default 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.



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default 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.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default 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.




  #4   Report Post  
Posted to microsoft.public.excel.programming
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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sum of different value in different worksheet & cell number Values sum in Multuiple Worksheet/cell Excel Worksheet Functions 2 January 23rd 10 12:21 AM
TOC: the first page number of each worksheet annoni Excel Discussion (Misc queries) 1 July 12th 08 05:30 AM
Finding the number of a worksheet GeorgeJ Excel Discussion (Misc queries) 2 July 27th 07 09:02 PM
Enter number on a worksheet to copy row from another worksheet 1SG Excel Worksheet Functions 1 May 22nd 07 12:15 AM
Basic Question - How do I return the worksheet number of the active worksheet? Regnab Excel Programming 2 May 17th 06 03:02 AM


All times are GMT +1. The time now is 03:09 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"