PC Review


Reply
Thread Tools Rate Thread

Code to create a new worksheet (based on an original pre-format sheet)

 
 
Mikey C
Guest
Posts: n/a
 
      29th Mar 2007
Hi all

I'm trying to create a command button which will copy an existing pre-
format worksheet (which I will probably hide) and insert the copied
sheet into the existing workbook but I have no idea how to do this! I
want to do this so users can create their own records without messing-
up the overall format (and make it simpler for them).

Can anybody help me?

Thanks

Mike

 
Reply With Quote
 
 
 
 
=?Utf-8?B?R2FyeScncyBTdHVkZW50?=
Guest
Posts: n/a
 
      29th Mar 2007
Sub newsheet()
n = Worksheets.Count
Sheets("Special").Copy After:=Sheets(n)
End Sub
Sub button_maker()
Application.CommandBars("Forms").Visible = True
ActiveSheet.Buttons.Add(290.25, 69, 51.75, 41.25).Select
Selection.OnAction = "newsheet"
Application.CommandBars("Forms").Visible = False
End Sub

button_maker just creates a typical "forms" button. Once run, it can be
discarded. newsheet will create a copy of a sheet called "Special" and put
it at the end. Modify as you require.
--
Gary's Student
gsnu200712


"Mikey C" wrote:

> Hi all
>
> I'm trying to create a command button which will copy an existing pre-
> format worksheet (which I will probably hide) and insert the copied
> sheet into the existing workbook but I have no idea how to do this! I
> want to do this so users can create their own records without messing-
> up the overall format (and make it simpler for them).
>
> Can anybody help me?
>
> Thanks
>
> Mike
>
>

 
Reply With Quote
 
Pete_UK
Guest
Posts: n/a
 
      30th Mar 2007
Here's a snippet of code to copy the sheet "template" and then rename
it to "new_name":

my_temp = "template" ' <==change to suit
my_new_sheet = "new_name" ' <== change to suit

Sheets(my_temp).Select
Sheets(my_temp).Copy After:=Sheets(1)
'change sheet name
Sheets(my_temp & " (2)").Name = my_new_sheet

You will need to detect if a sheet with that name already exists (if
the User invokes the macro more than once).

Hope this helps.

Pete

On Mar 29, 3:37 pm, "Mikey C" <m.crin...@gmail.com> wrote:
> Hi all
>
> I'm trying to create a command button which will copy an existing pre-
> format worksheet (which I will probably hide) and insert the copied
> sheet into the existing workbook but I have no idea how to do this! I
> want to do this so users can create their own records without messing-
> up the overall format (and make it simpler for them).
>
> Can anybody help me?
>
> Thanks
>
> Mike



 
Reply With Quote
 
Mikey C
Guest
Posts: n/a
 
      30th Mar 2007
Perfect - thanks Pete :-)

 
Reply With Quote
 
Pete_UK
Guest
Posts: n/a
 
      30th Mar 2007
You're welcome - thanks for feeding back.

Pete

On Mar 30, 10:22 am, "Mikey C" <m.crin...@gmail.com> wrote:
> Perfect - thanks Pete :-)



 
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
Keep Original Sheets Font Format when Populating data into other sheet Corey .... Microsoft Excel Programming 3 5th Jun 2008 01:54 AM
Code to create a list of records in another sheet, based on the entryof the word "Terminated" in a given column Mike C Microsoft Excel Programming 1 15th May 2008 01:43 AM
Code to create worksheet names based on the values in the selectedrange Mike C Microsoft Excel Programming 2 17th Mar 2008 12:33 AM
Create new sheets based off Data sheet, and template sheet Midget Microsoft Excel Programming 2 1st May 2007 09:55 PM
Search All worksheets for string & Create new Whorsheet with the Original Sheet Name and some cells.d some Dennis Whaley Microsoft Excel Discussion 3 7th Oct 2003 05:34 PM


Features
 

Advertising
 

Newsgroups
 


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