PC Review


Reply
Thread Tools Rate Thread

Copy sheet and rename tab

 
 
Kerry
Guest
Posts: n/a
 
      28th May 2009
Hi,
I have a time sheet that I use at work that I want to improve upon. We use
excel 2003. There is a button that prints out the time sheet then clears the
sheet ready for the next fortnight. What I want it to do is print it out,
then copy the sheet into the same workbook and rename the tab. I have put a
formula in cell A81 which is formatted so as to name the new tab. Below is
the code that already exists to print out and reset the sheet. I tried
recording a macro and entering the code but it wouldn't change the tab name.
What code will I need to enter to copy the sheet and rename it. I am not a
programmer so cannot do this myself. I would appreciate any help.

Thankyou
--
Kerry

Sub newtsheet()

Sheets("Timesheet").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1

Range("AS25").Select
Selection.Copy
Range("C17").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("AS29").Select
Application.CutCopyMode = False
Selection.Copy
Range("B30").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range( _

"C27:C28,F27:F28,I27:I28,L27:L28,O27:O28,R27:R28,U27:U28,X27:X28,AA27:AA28,AD27:AD28,AG27:AG28,AJ27:AJ28,AM27:AM28,AP27:AP28,C18:C23,F18:F23,I18:I23,L18:L23,O18:O23,X18:X23,AA18:AA23,AD18:AD23,AG18:AG23,AJ18:AJ23" _
).Select
Range("AJ23").Activate
ActiveWindow.LargeScroll Down:=-1
Union(Range( _

"AG11:AG14,AJ11:AJ14,AJ6:AJ9,AG6:AG9,AD6:AD9,AA6:AA9,X6:X9,O6:O9,L6:L9,I6:I9,F6:F9,C6:C9,C27:C28,F27:F28,I27:I28,L27:L28,O27:O28,R27:R28,U27:U28,X27:X28,AA27:AA28,AD27:AD28,AG27:AG28,AJ27:AJ28,AM27:AM28,AP27:AP28,C18:C23,F18:F23,I18:I23,L18:L23,O18:O23" _
), Range( _

"X18:X23,AA18:AA23,AD18:AD23,AG18:AG23,AJ18:AJ23,C11:C14,F11:F14,I11:I14,L11:L14,O11:O14,X11:X14,AA11:AA14,AD11:AD14,R6:R9,R11:R14,R18:R23,U6:U9,U11:U14,U18:U23,AM6:AM9,AM11:AM14,AM18:AM23,AP6:AP9,AP11:AP14,AP18:AP23" _
)).Select
Range("C6").Activate
Application.CutCopyMode = False
Selection.ClearContents
Range("B5").Select
Selection.Copy
ActiveWindow.LargeScroll Down:=3
Range("A80").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Range("B5").Select
ActiveCell.FormulaR1C1 = "=R[75]C[-1]+14"

Range("b4").Select
TitleText = InputBox( _
prompt:="Please enter fortnight number.", _
Default:="__")
ActiveCell.FormulaR1C1 = TitleText
Range("C6").Select
End Sub
 
Reply With Quote
 
 
 
 
Gary''s Student
Guest
Posts: n/a
 
      28th May 2009
Sub MakeACopy()
ActiveSheet.Copy after:=ActiveSheet
ActiveSheet.Name = Application.InputBox(prompt:="enter new sheet name",
Type:=2)
End Sub

--
Gary''s Student - gsnu200855


"Kerry" wrote:

> Hi,
> I have a time sheet that I use at work that I want to improve upon. We use
> excel 2003. There is a button that prints out the time sheet then clears the
> sheet ready for the next fortnight. What I want it to do is print it out,
> then copy the sheet into the same workbook and rename the tab. I have put a
> formula in cell A81 which is formatted so as to name the new tab. Below is
> the code that already exists to print out and reset the sheet. I tried
> recording a macro and entering the code but it wouldn't change the tab name.
> What code will I need to enter to copy the sheet and rename it. I am not a
> programmer so cannot do this myself. I would appreciate any help.
>
> Thankyou
> --
> Kerry
>
> Sub newtsheet()
>
> Sheets("Timesheet").Select
> ActiveWindow.SelectedSheets.PrintOut Copies:=1
>
> Range("AS25").Select
> Selection.Copy
> Range("C17").Select
> Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
> SkipBlanks:=False, Transpose:=False
> Range("AS29").Select
> Application.CutCopyMode = False
> Selection.Copy
> Range("B30").Select
> Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
> SkipBlanks:=False, Transpose:=False
> Range( _
>
> "C27:C28,F27:F28,I27:I28,L27:L28,O27:O28,R27:R28,U27:U28,X27:X28,AA27:AA28,AD27:AD28,AG27:AG28,AJ27:AJ28,AM27:AM28,AP27:AP28,C18:C23,F18:F23,I18:I23,L18:L23,O18:O23,X18:X23,AA18:AA23,AD18:AD23,AG18:AG23,AJ18:AJ23" _
> ).Select
> Range("AJ23").Activate
> ActiveWindow.LargeScroll Down:=-1
> Union(Range( _
>
> "AG11:AG14,AJ11:AJ14,AJ6:AJ9,AG6:AG9,AD6:AD9,AA6:AA9,X6:X9,O6:O9,L6:L9,I6:I9,F6:F9,C6:C9,C27:C28,F27:F28,I27:I28,L27:L28,O27:O28,R27:R28,U27:U28,X27:X28,AA27:AA28,AD27:AD28,AG27:AG28,AJ27:AJ28,AM27:AM28,AP27:AP28,C18:C23,F18:F23,I18:I23,L18:L23,O18:O23" _
> ), Range( _
>
> "X18:X23,AA18:AA23,AD18:AD23,AG18:AG23,AJ18:AJ23,C11:C14,F11:F14,I11:I14,L11:L14,O11:O14,X11:X14,AA11:AA14,AD11:AD14,R6:R9,R11:R14,R18:R23,U6:U9,U11:U14,U18:U23,AM6:AM9,AM11:AM14,AM18:AM23,AP6:AP9,AP11:AP14,AP18:AP23" _
> )).Select
> Range("C6").Activate
> Application.CutCopyMode = False
> Selection.ClearContents
> Range("B5").Select
> Selection.Copy
> ActiveWindow.LargeScroll Down:=3
> Range("A80").Select
> Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
> SkipBlanks:=False, Transpose:=False
> Application.CutCopyMode = False
> Range("B5").Select
> ActiveCell.FormulaR1C1 = "=R[75]C[-1]+14"
>
> Range("b4").Select
> TitleText = InputBox( _
> prompt:="Please enter fortnight number.", _
> Default:="__")
> ActiveCell.FormulaR1C1 = TitleText
> Range("C6").Select
> End Sub

 
Reply With Quote
 
Kerry
Guest
Posts: n/a
 
      28th May 2009
Hi Gary"s Student,
I entered the code but it said syntax error on the activesheet.name line. Is
it possible to enter this code directly into the existing code?
Thanks for your help.

Kerry


"Gary''s Student" wrote:

> Sub MakeACopy()
> ActiveSheet.Copy after:=ActiveSheet
> ActiveSheet.Name = Application.InputBox(prompt:="enter new sheet name",
> Type:=2)
> End Sub
>
> --
> Gary''s Student - gsnu200855
>
>
> "Kerry" wrote:
>
> > Hi,
> > I have a time sheet that I use at work that I want to improve upon. We use
> > excel 2003. There is a button that prints out the time sheet then clears the
> > sheet ready for the next fortnight. What I want it to do is print it out,
> > then copy the sheet into the same workbook and rename the tab. I have put a
> > formula in cell A81 which is formatted so as to name the new tab. Below is
> > the code that already exists to print out and reset the sheet. I tried
> > recording a macro and entering the code but it wouldn't change the tab name.
> > What code will I need to enter to copy the sheet and rename it. I am not a
> > programmer so cannot do this myself. I would appreciate any help.
> >
> > Thankyou
> > --
> > Kerry
> >
> > Sub newtsheet()
> >
> > Sheets("Timesheet").Select
> > ActiveWindow.SelectedSheets.PrintOut Copies:=1
> >
> > Range("AS25").Select
> > Selection.Copy
> > Range("C17").Select
> > Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
> > SkipBlanks:=False, Transpose:=False
> > Range("AS29").Select
> > Application.CutCopyMode = False
> > Selection.Copy
> > Range("B30").Select
> > Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
> > SkipBlanks:=False, Transpose:=False
> > Range( _
> >
> > "C27:C28,F27:F28,I27:I28,L27:L28,O27:O28,R27:R28,U27:U28,X27:X28,AA27:AA28,AD27:AD28,AG27:AG28,AJ27:AJ28,AM27:AM28,AP27:AP28,C18:C23,F18:F23,I18:I23,L18:L23,O18:O23,X18:X23,AA18:AA23,AD18:AD23,AG18:AG23,AJ18:AJ23" _
> > ).Select
> > Range("AJ23").Activate
> > ActiveWindow.LargeScroll Down:=-1
> > Union(Range( _
> >
> > "AG11:AG14,AJ11:AJ14,AJ6:AJ9,AG6:AG9,AD6:AD9,AA6:AA9,X6:X9,O6:O9,L6:L9,I6:I9,F6:F9,C6:C9,C27:C28,F27:F28,I27:I28,L27:L28,O27:O28,R27:R28,U27:U28,X27:X28,AA27:AA28,AD27:AD28,AG27:AG28,AJ27:AJ28,AM27:AM28,AP27:AP28,C18:C23,F18:F23,I18:I23,L18:L23,O18:O23" _
> > ), Range( _
> >
> > "X18:X23,AA18:AA23,AD18:AD23,AG18:AG23,AJ18:AJ23,C11:C14,F11:F14,I11:I14,L11:L14,O11:O14,X11:X14,AA11:AA14,AD11:AD14,R6:R9,R11:R14,R18:R23,U6:U9,U11:U14,U18:U23,AM6:AM9,AM11:AM14,AM18:AM23,AP6:AP9,AP11:AP14,AP18:AP23" _
> > )).Select
> > Range("C6").Activate
> > Application.CutCopyMode = False
> > Selection.ClearContents
> > Range("B5").Select
> > Selection.Copy
> > ActiveWindow.LargeScroll Down:=3
> > Range("A80").Select
> > Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
> > SkipBlanks:=False, Transpose:=False
> > Application.CutCopyMode = False
> > Range("B5").Select
> > ActiveCell.FormulaR1C1 = "=R[75]C[-1]+14"
> >
> > Range("b4").Select
> > TitleText = InputBox( _
> > prompt:="Please enter fortnight number.", _
> > Default:="__")
> > ActiveCell.FormulaR1C1 = TitleText
> > Range("C6").Select
> > End Sub

 
Reply With Quote
 
Gary''s Student
Guest
Posts: n/a
 
      29th May 2009
Make sure text wrapping is not killing you.

Prompt:= and Type:= are all part of a single line!
--
Gary''s Student - gsnu200855


"Kerry" wrote:

> Hi Gary"s Student,
> I entered the code but it said syntax error on the activesheet.name line. Is
> it possible to enter this code directly into the existing code?
> Thanks for your help.
>
> Kerry
>
>
> "Gary''s Student" wrote:
>
> > Sub MakeACopy()
> > ActiveSheet.Copy after:=ActiveSheet
> > ActiveSheet.Name = Application.InputBox(prompt:="enter new sheet name",
> > Type:=2)
> > End Sub
> >
> > --
> > Gary''s Student - gsnu200855
> >
> >
> > "Kerry" wrote:
> >
> > > Hi,
> > > I have a time sheet that I use at work that I want to improve upon. We use
> > > excel 2003. There is a button that prints out the time sheet then clears the
> > > sheet ready for the next fortnight. What I want it to do is print it out,
> > > then copy the sheet into the same workbook and rename the tab. I have put a
> > > formula in cell A81 which is formatted so as to name the new tab. Below is
> > > the code that already exists to print out and reset the sheet. I tried
> > > recording a macro and entering the code but it wouldn't change the tab name.
> > > What code will I need to enter to copy the sheet and rename it. I am not a
> > > programmer so cannot do this myself. I would appreciate any help.
> > >
> > > Thankyou
> > > --
> > > Kerry
> > >
> > > Sub newtsheet()
> > >
> > > Sheets("Timesheet").Select
> > > ActiveWindow.SelectedSheets.PrintOut Copies:=1
> > >
> > > Range("AS25").Select
> > > Selection.Copy
> > > Range("C17").Select
> > > Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
> > > SkipBlanks:=False, Transpose:=False
> > > Range("AS29").Select
> > > Application.CutCopyMode = False
> > > Selection.Copy
> > > Range("B30").Select
> > > Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
> > > SkipBlanks:=False, Transpose:=False
> > > Range( _
> > >
> > > "C27:C28,F27:F28,I27:I28,L27:L28,O27:O28,R27:R28,U27:U28,X27:X28,AA27:AA28,AD27:AD28,AG27:AG28,AJ27:AJ28,AM27:AM28,AP27:AP28,C18:C23,F18:F23,I18:I23,L18:L23,O18:O23,X18:X23,AA18:AA23,AD18:AD23,AG18:AG23,AJ18:AJ23" _
> > > ).Select
> > > Range("AJ23").Activate
> > > ActiveWindow.LargeScroll Down:=-1
> > > Union(Range( _
> > >
> > > "AG11:AG14,AJ11:AJ14,AJ6:AJ9,AG6:AG9,AD6:AD9,AA6:AA9,X6:X9,O6:O9,L6:L9,I6:I9,F6:F9,C6:C9,C27:C28,F27:F28,I27:I28,L27:L28,O27:O28,R27:R28,U27:U28,X27:X28,AA27:AA28,AD27:AD28,AG27:AG28,AJ27:AJ28,AM27:AM28,AP27:AP28,C18:C23,F18:F23,I18:I23,L18:L23,O18:O23" _
> > > ), Range( _
> > >
> > > "X18:X23,AA18:AA23,AD18:AD23,AG18:AG23,AJ18:AJ23,C11:C14,F11:F14,I11:I14,L11:L14,O11:O14,X11:X14,AA11:AA14,AD11:AD14,R6:R9,R11:R14,R18:R23,U6:U9,U11:U14,U18:U23,AM6:AM9,AM11:AM14,AM18:AM23,AP6:AP9,AP11:AP14,AP18:AP23" _
> > > )).Select
> > > Range("C6").Activate
> > > Application.CutCopyMode = False
> > > Selection.ClearContents
> > > Range("B5").Select
> > > Selection.Copy
> > > ActiveWindow.LargeScroll Down:=3
> > > Range("A80").Select
> > > Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
> > > SkipBlanks:=False, Transpose:=False
> > > Application.CutCopyMode = False
> > > Range("B5").Select
> > > ActiveCell.FormulaR1C1 = "=R[75]C[-1]+14"
> > >
> > > Range("b4").Select
> > > TitleText = InputBox( _
> > > prompt:="Please enter fortnight number.", _
> > > Default:="__")
> > > ActiveCell.FormulaR1C1 = TitleText
> > > Range("C6").Select
> > > End Sub

 
Reply With Quote
 
Kerry
Guest
Posts: n/a
 
      29th May 2009
That works thankyou. That is one way of solving the copy and rename problem.
I will continue to work on the program so that when I press the new worksheet
button it will print it out then copy and rename automatically and clear the
old time sheet.

Thankyou very much for your help Gary"s Student.
--
Kerry


"Gary''s Student" wrote:

> Make sure text wrapping is not killing you.
>
> Prompt:= and Type:= are all part of a single line!
> --
> Gary''s Student - gsnu200855
>
>
> "Kerry" wrote:
>
> > Hi Gary"s Student,
> > I entered the code but it said syntax error on the activesheet.name line. Is
> > it possible to enter this code directly into the existing code?
> > Thanks for your help.
> >
> > Kerry
> >
> >
> > "Gary''s Student" wrote:
> >
> > > Sub MakeACopy()
> > > ActiveSheet.Copy after:=ActiveSheet
> > > ActiveSheet.Name = Application.InputBox(prompt:="enter new sheet name",
> > > Type:=2)
> > > End Sub
> > >
> > > --
> > > Gary''s Student - gsnu200855
> > >
> > >
> > > "Kerry" wrote:
> > >
> > > > Hi,
> > > > I have a time sheet that I use at work that I want to improve upon. We use
> > > > excel 2003. There is a button that prints out the time sheet then clears the
> > > > sheet ready for the next fortnight. What I want it to do is print it out,
> > > > then copy the sheet into the same workbook and rename the tab. I have put a
> > > > formula in cell A81 which is formatted so as to name the new tab. Below is
> > > > the code that already exists to print out and reset the sheet. I tried
> > > > recording a macro and entering the code but it wouldn't change the tab name.
> > > > What code will I need to enter to copy the sheet and rename it. I am not a
> > > > programmer so cannot do this myself. I would appreciate any help.
> > > >
> > > > Thankyou
> > > > --
> > > > Kerry
> > > >
> > > >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy and rename a sheet Ticotion Microsoft Excel Programming 2 18th Jan 2010 03:00 PM
Copy sheet and rename LiAD Microsoft Excel Programming 5 5th Nov 2009 02:38 PM
How to copy a sheet and rename it with the value of two cells from the source sheet? Simon Lloyd Microsoft Excel Programming 0 12th May 2006 01:31 AM
Button to copy sheet, rename sheet sequencially. foxgguy2005 Microsoft Excel Programming 9 17th Jun 2005 01:41 PM
Copy a sheet and rename it =?Utf-8?B?cXVhcnR6?= Microsoft Excel Programming 4 24th Mar 2005 09:36 PM


Features
 

Advertising
 

Newsgroups
 


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