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

Hi

I'm trying to copy the active sheet via VBA and renaming it according to a
cell value found in a master data sheet. The sheet that is copied is to be
placed after the originalsheet (orgsh). I use the following code:

Set orgSh = ActiveSheet
Set newSh = ActiveSheet.Copy(After:=ActiveSheet)
newSh.Name = "Week" & " " & Sheets("Stamdata").Range("A4").Value

But I get an error referring to line 2.

Can you help?

Thank you

Ticotion
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy and rename a sheet

I use this code in some of my Workbooks.

Sub Copy
ActiveSheet.Copy After:=ActiveSheet
ActiveSheet.Name = Range("$A$1")

First line says that the active sheet should be copy and placed after the
activesheet. Then the second line of code will change the name in what is in
cell A1. I made a module and placed this lines in it. You can then make a
button or what ever you want.

Hope you can use it.

Greets Tom


"Ticotion" wrote:

Hi

I'm trying to copy the active sheet via VBA and renaming it according to a
cell value found in a master data sheet. The sheet that is copied is to be
placed after the originalsheet (orgsh). I use the following code:

Set orgSh = ActiveSheet
Set newSh = ActiveSheet.Copy(After:=ActiveSheet)
newSh.Name = "Week" & " " & Sheets("Stamdata").Range("A4").Value

But I get an error referring to line 2.

Can you help?

Thank you

Ticotion

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Copy and rename a sheet

That worked.

Thank you

"Kruijf" wrote:

I use this code in some of my Workbooks.

Sub Copy
ActiveSheet.Copy After:=ActiveSheet
ActiveSheet.Name = Range("$A$1")

First line says that the active sheet should be copy and placed after the
activesheet. Then the second line of code will change the name in what is in
cell A1. I made a module and placed this lines in it. You can then make a
button or what ever you want.

Hope you can use it.

Greets Tom


"Ticotion" wrote:

Hi

I'm trying to copy the active sheet via VBA and renaming it according to a
cell value found in a master data sheet. The sheet that is copied is to be
placed after the originalsheet (orgsh). I use the following code:

Set orgSh = ActiveSheet
Set newSh = ActiveSheet.Copy(After:=ActiveSheet)
newSh.Name = "Week" & " " & Sheets("Stamdata").Range("A4").Value

But I get an error referring to line 2.

Can you help?

Thank you

Ticotion

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
Copy sheet and rename LiAD Excel Programming 5 November 5th 09 02:38 PM
Copy sheet and rename tab Kerry Excel Programming 4 May 29th 09 09:36 AM
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
Copy a sheet and rename it quartz[_2_] Excel Programming 4 March 24th 05 09:36 PM


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