The Code Cage - Microsoft Office help Free Microsoft Office Help for all Applications!  

To stop seeing these ads and get other benefits check This page!

Go Back   The Code Cage Forums > Newsgroups - Microsoft Topics > Newsgroup - Excel Forum > Worksheet Functions


Worksheet Functions Post questions in this forum if they are related to using Microsoft Excel Worksheet Functions, e.g Forumale or built in functionality etc.

Hey there!

It looks like you're enjoying but haven't created an account yet. Why not take a minute to register for your own free account now? As a member you get free access to all of our forums and posts plus the ability to post your own messages, communicate directly with other members and much more. Register now!

Already a member? Login at the top of this page to stop seeing this message.


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10th July 2009, 12:04 AM
Robert
Newsgroup Contributor


My Top Tip Count:

 
Posts: n/a
Default make copies of sheet and name them from list

------ Register to get rid of these "In Post" ads! ------


Hello,
I have about 50 employee numbers in sheet1 A:A. Is there code for a macro
that can make a copy of sheet2 for each instance of employee number and name
it with the employee number as the sheet name?

thanks in advance for any help,
Robert
Reply to this post


Did you find this post helpful? Yes | No
The Code Cage Advertisment
Advertisement

To stop seeing these ads and get other benefits check This page!
  #2 (permalink)  
Old 10th July 2009, 12:39 AM
Gord Dibben
Newsgroup Contributor


My Top Tip Count:

 
Posts: n/a
Default Re: make copies of sheet and name them from list

------ Register to get rid of these "In Post" ads! ------


Edit sheet names to suit where noted.

Sub CreateNameSheets()
' by Dave Peterson
' List sheetnames required in col A in a sheet: List
' Sub will copy sheets based on the sheet named as: Template
' and name the sheets accordingly

Dim TemplateWks As Worksheet
Dim ListWks As Worksheet
Dim ListRng As Range
Dim mycell As Range

Set TemplateWks = Worksheets("Template") 'change to "Sheet2"
Set ListWks = Worksheets("list") 'Change to "Sheet1"
With ListWks
Set ListRng = .Range("a1", .Cells(.Rows.Count, "A").End(xlUp))
End With

For Each mycell In ListRng.Cells
TemplateWks.Copy After:=Worksheets(Worksheets.Count)
On Error Resume Next
ActiveSheet.Name = mycell.Value
If Err.Number <> 0 Then
MsgBox "Please fix: " & ActiveSheet.Name
Err.Clear
End If
On Error GoTo 0
Next mycell

End Sub


Gord Dibben MS Excel MVP

On Thu, 9 Jul 2009 16:01:04 -0700, Robert <Robert@discussions.microsoft.com>
wrote:

>Hello,
>I have about 50 employee numbers in sheet1 A:A. Is there code for a macro
>that can make a copy of sheet2 for each instance of employee number and name
>it with the employee number as the sheet name?
>
>thanks in advance for any help,
>Robert


Reply to this post


Did you find this post helpful? Yes | No
  #3 (permalink)  
Old 10th July 2009, 12:45 AM
Don Guillett
Newsgroup Contributor


My Top Tip Count:

 
Posts: n/a
Default Re: make copies of sheet and name them from list

------ Register to get rid of these "In Post" ads! ------


Why not just use data>filter>autofilter?

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
dguillett1@austin.rr.com
"Robert" <Robert@discussions.microsoft.com> wrote in message
news:9BBDF8FA-5877-4EAD-9884-A045A7461F7B@microsoft.com...
> Hello,
> I have about 50 employee numbers in sheet1 A:A. Is there code for a macro
> that can make a copy of sheet2 for each instance of employee number and
> name
> it with the employee number as the sheet name?
>
> thanks in advance for any help,
> Robert


Reply to this post


Did you find this post helpful? Yes | No
The Code Cage Advertisment
Advertisement

To stop seeing these ads and get other benefits check This page!
  #4 (permalink)  
Old 10th July 2009, 02:13 AM
Shane Devenshire
Newsgroup Contributor


My Top Tip Count:

 
Posts: n/a
Default RE: make copies of sheet and name them from list

------ Register to get rid of these "In Post" ads! ------


Hi,

Well I finally get a use for this feature:

1. Higlight the employee numbes in Column A and choose Data, Pivot Table and
Pivot Chart Report, click Next, Next and choose Existing worksheet and pick
an empty range starting on row 3 or lower, say D4, and click Finish.
2. Drop the title for the Employee # field in the Page Field area.
3. With the pivot table selected choose PivotTable, Show Pages and click OK.

4. Since you probably don't need the pivot tables, select the first employee
sheet tab, how down the shift key and click the last employee sheet tab.
5. Select the range with the pivot tables (empty ones) and press Delete.


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

Cheers,
Shane Devenshire


"Robert" wrote:

> Hello,
> I have about 50 employee numbers in sheet1 A:A. Is there code for a macro
> that can make a copy of sheet2 for each instance of employee number and name
> it with the employee number as the sheet name?
>
> thanks in advance for any help,
> Robert

Reply to this post


Did you find this post helpful? Yes | No
  #5 (permalink)  
Old 10th July 2009, 05:07 AM
Robert
Newsgroup Contributor


My Top Tip Count:

 
Posts: n/a
Default Re: make copies of sheet and name them from list

------ Register to get rid of these "In Post" ads! ------


Thanks Gord! It worked...there were a few errors "Please fix", but I just
kept cancelling and it took off and made all the sheets. Just for fun, I
tried to change the range to A6:A51 where the actual numbers are but I got VB
errors. Maybe the headers rows gave problems. I should have been more
specific. In any case, this saved me tons of time and I very much appreciate
it!
Robert

"Gord Dibben" wrote:

> Edit sheet names to suit where noted.
>
> Sub CreateNameSheets()
> ' by Dave Peterson
> ' List sheetnames required in col A in a sheet: List
> ' Sub will copy sheets based on the sheet named as: Template
> ' and name the sheets accordingly
>
> Dim TemplateWks As Worksheet
> Dim ListWks As Worksheet
> Dim ListRng As Range
> Dim mycell As Range
>
> Set TemplateWks = Worksheets("Template") 'change to "Sheet2"
> Set ListWks = Worksheets("list") 'Change to "Sheet1"
> With ListWks
> Set ListRng = .Range("a1", .Cells(.Rows.Count, "A").End(xlUp))
> End With
>
> For Each mycell In ListRng.Cells
> TemplateWks.Copy After:=Worksheets(Worksheets.Count)
> On Error Resume Next
> ActiveSheet.Name = mycell.Value
> If Err.Number <> 0 Then
> MsgBox "Please fix: " & ActiveSheet.Name
> Err.Clear
> End If
> On Error GoTo 0
> Next mycell
>
> End Sub
>
>
> Gord Dibben MS Excel MVP
>
> On Thu, 9 Jul 2009 16:01:04 -0700, Robert <Robert@discussions.microsoft.com>
> wrote:
>
> >Hello,
> >I have about 50 employee numbers in sheet1 A:A. Is there code for a macro
> >that can make a copy of sheet2 for each instance of employee number and name
> >it with the employee number as the sheet name?
> >
> >thanks in advance for any help,
> >Robert

>
>

Reply to this post


Did you find this post helpful? Yes | No
The Code Cage Advertisment
Advertisement

To stop seeing these ads and get other benefits check This page!
Reply

Bookmarks

Tags
copies, list, make, sheet

New topics in Worksheet Functions


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

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

Forum Jump

The Code Cage Affilliates


To stop seeing these ads and get other benefits check This page!



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


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2
No part of this board may be copied or reproduced either in part or full without the express permission of The Code Cage Team.
We are not associated with nor employed by Microsoft in any way, we simply provide resources!
All MS office icons are registered trademarks of the application the represent