Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default rename a copied sheet

I am trying to write a simple VBA program for a spreadsheet. However
I
am stuck. I am learning this as I go along so that is the big problem
no doubt. I need to copy a sheet and rename. Simple eh? I copy it no
problem but cannot figure how to change the copyed name (now
firstname(2) for instance) to a new name. A cut out of the utility is
below:

Private Sub copysht()
sname = "dog"
Sheets("Template").Copy after:=Worksheets(Worksheets.Count)
'.name
= "sname" 'copy at the end
Sheets("Template(2)").name = "sname"
'ActiveWorkbook.Sheets("Template(2)").name = "sname" 'give sheet a
new
name but it blows up on Template(2)!
End Sub
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default rename a copied sheet

On Mar 4, 8:57*pm, Gord Dibben <gorddibbATshawDOTca wrote:
Note that the copied sheet name Template (2) has a space.

Add that to your macro.

Private Sub copysht()
* * sname = "dog"
* * Sheets("Template").Copy after:=Worksheets(Worksheets.Count)
* * Sheets("Template (2)").Name = sname
End Sub

Gord Dibben *MS Excel MVP



On Tue, 4 Mar 2008 12:18:13 -0800 (PST), wrote:
I am trying to write a simple VBA program for a spreadsheet. However
I
am stuck. I am learning this as I go along so that is the big problem
no doubt. I need to copy a sheet and rename. Simple eh? I copy it no
problem but cannot figure how to change the copyed name (now
firstname(2) for instance) to a new name. A cut out of the utility is
below:


Private Sub copysht()
* *sname = "dog"
* *Sheets("Template").Copy after:=Worksheets(Worksheets.Count)
'.name
= "sname" 'copy at the end
* *Sheets("Template(2)").name = "sname"
'ActiveWorkbook.Sheets("Template(2)").name = "sname" 'give sheet a
new
name but it blows up on Template(2)!
End Sub- Hide quoted text -


- Show quoted text -


Bloody Hell! You're right! Main I worked all day trying every combo
possible and never thought there was a space there. Thanks very much!!

Wayne
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default rename a copied sheet

New eyes.........new view<g


Gord

On Tue, 4 Mar 2008 14:07:21 -0800 (PST), wrote:

Bloody Hell! You're right! Main I worked all day trying every combo
possible and never thought there was a space there. Thanks very much!!

Wayne


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
how do i rename a sheet if the rename tab is inactive? Nelson Excel Worksheet Functions 1 March 3rd 10 10:28 AM
macro to: Add new sheet, then rename new sheet with todays date Paul Excel Worksheet Functions 3 September 29th 07 03:17 AM
Move data to new sheet - rename sheet based on criteria ? [email protected] Excel Discussion (Misc queries) 7 May 16th 07 10:22 PM
How to copy a sheet and rename it with the value of two cells from the source sheet? Simon Lloyd[_717_] Excel Programming 0 May 12th 06 01:31 AM
Button to copy sheet, rename sheet sequencially. foxgguy2005[_3_] Excel Programming 9 June 17th 05 01:41 PM


All times are GMT +1. The time now is 08:25 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"