A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Copy sheet



 
 
Thread Tools Display Modes
  #1  
Old March 10th, 2009, 01:30 PM posted to microsoft.public.excel.newusers
Paul
external usenet poster
 
Posts: 35
Default Copy sheet

Hi, I have a time sheet (only one sheet in the workbook), at end of
each 4 week period users clicks new month - this clears sheet, puts
new dates in and carries forward current hours (credit, debit).

I want to be able the workbook to save a copy to a new sheet (within
same workbook), then clear times etc in main sheet (Sheet1 only). I
have the following which works but want to rename the new sheet
(Sheet1 (2) ) to Period 1, then next month period 2 etc. Thanks


Sub CopySheet()
Sheets("Sheet1").Select
Sheets("Sheet1").Copy After:=Sheets(2)
Sheets("Sheet1 (2)").Select
ActiveWorkbook.Sheets("Sheet1 (2)").Tab.ColorIndex = 35
Sheets("Sheet1").Select
End Sub
  #2  
Old March 10th, 2009, 02:01 PM posted to microsoft.public.excel.newusers
Per Jessen
external usenet poster
 
Posts: 686
Default Copy sheet

Hi

Try this:

Sub CopySheet()
If Sheets(Sheets.Count).Name Like "Period*" Then
Period = Mid(Sheets(Sheets.Count).Name, 7)
Period = Period + 1
Else
Period = 1
End If
Sheets("Sheet1").Copy After:=Sheets(Sheets.Count)
Sheets("Sheet1 (2)").Select
ActiveWorkbook.Sheets("Sheet1 (2)").Tab.ColorIndex = 35
Sheets(Sheets.Count).Name = "Period" & Period
Sheets("Sheet1").Select
End Sub

Regards,
Per

"Paul" skrev i meddelelsen
...
Hi, I have a time sheet (only one sheet in the workbook), at end of
each 4 week period users clicks new month - this clears sheet, puts
new dates in and carries forward current hours (credit, debit).

I want to be able the workbook to save a copy to a new sheet (within
same workbook), then clear times etc in main sheet (Sheet1 only). I
have the following which works but want to rename the new sheet
(Sheet1 (2) ) to Period 1, then next month period 2 etc. Thanks


Sub CopySheet()
Sheets("Sheet1").Select
Sheets("Sheet1").Copy After:=Sheets(2)
Sheets("Sheet1 (2)").Select
ActiveWorkbook.Sheets("Sheet1 (2)").Tab.ColorIndex = 35
Sheets("Sheet1").Select
End Sub


  #3  
Old March 10th, 2009, 03:01 PM posted to microsoft.public.excel.newusers
Shane Devenshire
external usenet poster
 
Posts: 845
Default Copy sheet

Hi,

I'm not sure where you want to put the sheet because if your workbook only
has one sheet I don't see how it can add the next sheet after sheet(2).
However, lets assume you want to add the new sheet directly after the sheet
you are on.

Sub CopySheet()
ActiveSheet.Copy After:=ActiveSheet
ActiveSheet.Tab.ColorIndex = 35
ActiveSheet.Name = "Period" & Sheets.Count - 1
End Sub

--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire


"Paul" wrote:

Hi, I have a time sheet (only one sheet in the workbook), at end of
each 4 week period users clicks new month - this clears sheet, puts
new dates in and carries forward current hours (credit, debit).

I want to be able the workbook to save a copy to a new sheet (within
same workbook), then clear times etc in main sheet (Sheet1 only). I
have the following which works but want to rename the new sheet
(Sheet1 (2) ) to Period 1, then next month period 2 etc. Thanks


Sub CopySheet()
Sheets("Sheet1").Select
Sheets("Sheet1").Copy After:=Sheets(2)
Sheets("Sheet1 (2)").Select
ActiveWorkbook.Sheets("Sheet1 (2)").Tab.ColorIndex = 35
Sheets("Sheet1").Select
End Sub

  #4  
Old March 10th, 2009, 03:08 PM posted to microsoft.public.excel.newusers
Paul
external usenet poster
 
Posts: 35
Default Copy sheet

On Mar 10, 2:01*pm, "Per Jessen" wrote:
Hi

Try this:

Sub CopySheet()
* * If Sheets(Sheets.Count).Name Like "Period*" Then
* * * * Period = Mid(Sheets(Sheets.Count).Name, 7)
* * * * Period = Period + 1
* * Else
* * * * Period = 1
* * End If
* * Sheets("Sheet1").Copy After:=Sheets(Sheets.Count)
* * Sheets("Sheet1 (2)").Select
* * ActiveWorkbook.Sheets("Sheet1 (2)").Tab.ColorIndex = 35
* * Sheets(Sheets.Count).Name = "Period" & Period
* * Sheets("Sheet1").Select
End Sub

Regards,
Per

"Paul" skrev i ...



Hi, I have a time sheet (only one sheet in the workbook), at end of
each 4 week period users clicks new month - this clears sheet, puts
new dates in and carries forward current hours (credit, debit).


I want to be able the workbook to save a copy to a new sheet (within
same workbook), then clear times etc in main sheet (Sheet1 only). I
have the following which works but want to rename the new sheet
(Sheet1 (2) ) to Period 1, then next month period 2 etc. Thanks


Sub CopySheet()
* *Sheets("Sheet1").Select
* *Sheets("Sheet1").Copy After:=Sheets(2)
* *Sheets("Sheet1 (2)").Select
* *ActiveWorkbook.Sheets("Sheet1 (2)").Tab.ColorIndex = 35
* *Sheets("Sheet1").Select
End Sub- Hide quoted text -


- Show quoted text -


Thank you very much, works well.
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:33 PM.


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