Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Renaming Problems

I am trying to get a macro to copy a worksheet and
rename it sheet sequentially. The way the macro needs
to be set up is so that, every time it copies the first
sheet and renames after the last sheet

The current name format is "Sheet1(2)"

Matt
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Renaming Problems

I understand you are trying to copy Sheet1 in a new sheet
in the same workbook, and what troubles you is the name of
the new sheet? For instance, if you already have 4 sheets,
you would want the new one to be named Sheet5 rather than
Sheet1(2)? Try the following after you have copied the
sheet:

shct = ActiveWorkbook.Sheets.Count
ActiveSheet.Name = "Sheet" & shct

Nikos Y.


-----Original Message-----
I am trying to get a macro to copy a worksheet and
rename it sheet sequentially. The way the macro needs
to be set up is so that, every time it copies the first
sheet and renames after the last sheet

The current name format is "Sheet1(2)"

Matt
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Renaming Problems

Thanks mate that worked and did just what I wanted.

Matt


"Nikos Yannacopoulos" wrote in message ...
I understand you are trying to copy Sheet1 in a new sheet
in the same workbook, and what troubles you is the name of
the new sheet? For instance, if you already have 4 sheets,
you would want the new one to be named Sheet5 rather than
Sheet1(2)? Try the following after you have copied the
sheet:

shct = ActiveWorkbook.Sheets.Count
ActiveSheet.Name = "Sheet" & shct

Nikos Y.


-----Original Message-----
I am trying to get a macro to copy a worksheet and
rename it sheet sequentially. The way the macro needs
to be set up is so that, every time it copies the first
sheet and renames after the last sheet

The current name format is "Sheet1(2)"

Matt
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Renaming Problems

Note that you'll get a run-time error with this if a sheet already
exists with that name. For instance, if you have 5 sheets to begin
with, delete Sheet2, then add a sheet, Sheets.Count will return 5
and ActiveSheet.Name = "Sheet" & shct will give an error.

You may want to prevent that with something like:

Dim shct As Integer
shct = ActiveWorkbook.Sheets.Count - 1
On Error Resume Next
Do
shct = shct + 1
ActiveSheet.Name = "Sheet" & shct
Loop Until ActiveSheet.Name = "Sheet" & shct
On Error GoTo 0




In article ,
"Nikos Yannacopoulos" wrote:

I understand you are trying to copy Sheet1 in a new sheet
in the same workbook, and what troubles you is the name of
the new sheet? For instance, if you already have 4 sheets,
you would want the new one to be named Sheet5 rather than
Sheet1(2)? Try the following after you have copied the
sheet:

shct = ActiveWorkbook.Sheets.Count
ActiveSheet.Name = "Sheet" & shct

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
RENAMING WORKSHEETS LEOPARDSHIDEAWAY Excel Worksheet Functions 1 July 26th 07 10:27 PM
Worksheet Renaming Eric Excel Discussion (Misc queries) 2 July 26th 07 02:44 PM
Worksheet Renaming Eric Excel Worksheet Functions 1 July 26th 07 02:38 PM
renaming problem CAMBUSBOY Excel Worksheet Functions 0 May 31st 05 09:01 AM
Renaming within VBA Brent McIntyre Excel Programming 4 August 21st 03 02:10 AM


All times are GMT +1. The time now is 05:01 PM.

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

About Us

"It's about Microsoft Excel"