Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Naming Worksheets with a Macro

I am trying to use a macro to create a copy of a worksheet. After inserting
sheet1 I can go it (worksheet("sheet1").select) then rename it to a standard
name. However, when I run the macro again, the next new sheet is now called
sheet2 which interferes with the macro that is looking for Sheet1. Is there
a way to use a formula to rename worksheets.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Naming Worksheets with a Macro

Barry,

This copies "Sheet1" (in the book with the macro) and renames the copy.
Change ThisWorkbook to ActiveWorkbook or other workbook name if the sheet to
be copied is not in the book with the macro:

Sub test()

With ThisWorkbook
.Worksheets("Sheet1").Copy after:=.Worksheets(.Worksheets.Count)
ActiveSheet.Name = "MySpecialName" 'the new copy is now the active sheet
End With

End Sub

hth,

Doug

"BarryL" wrote in message
...
I am trying to use a macro to create a copy of a worksheet. After
inserting
sheet1 I can go it (worksheet("sheet1").select) then rename it to a
standard
name. However, when I run the macro again, the next new sheet is now
called
sheet2 which interferes with the macro that is looking for Sheet1. Is
there
a way to use a formula to rename worksheets.



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
Naming worksheets within a macro GLS Excel Worksheet Functions 1 November 14th 06 09:51 AM
Naming worksheets... tojo107 Excel Discussion (Misc queries) 3 April 7th 05 07:29 PM
naming worksheets Shooter Excel Worksheet Functions 1 December 3rd 04 04:09 PM
Naming Worksheets in VBE Don Guillett[_4_] Excel Programming 0 July 18th 03 08:17 PM
Naming Worksheets in VBE Chip Pearson Excel Programming 0 July 18th 03 08:16 PM


All times are GMT +1. The time now is 08:37 PM.

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"