Excel to auto generate pages and copy the template of Page 1

baash

New Member
Joined
Nov 21, 2017
Messages
6
Hi
I have got a work book in page 1 I have a summary sheet (Lists of names) from which I have formulated it to other pages for cells fill up. So they all have a sample template i.e 1 page. i am trying that to automate like look at the lists and if it needs more than one page to fill up.Auto-generate the pages and copy the template with the the formula in them.
I have tried the code below but I am novice in VBA.


Any help would be appreciated.
Code:
[COLOR=#00007F][FONT=Courier]Sub[/FONT][/COLOR][COLOR=#333333][FONT=Courier] CreateAndNameWorksheets()[/FONT][/COLOR]
[COLOR=#00007F][FONT=Courier]Dim[/FONT][/COLOR][COLOR=#333333][FONT=Courier] c [/FONT][/COLOR][COLOR=#00007F][FONT=Courier]As[/FONT][/COLOR][COLOR=#333333][FONT=Courier] Range
[/FONT][/COLOR]                 

[COLOR=#333333][FONT=Courier]    Application.ScreenUpdating = [/FONT][/COLOR][COLOR=#00007F][FONT=Courier]False[/FONT][/COLOR]
[COLOR=#00007F][FONT=Courier]For[/FONT][/COLOR][COLOR=#00007F][FONT=Courier]Each[/FONT][/COLOR][COLOR=#333333][FONT=Courier] c [/FONT][/COLOR][COLOR=#00007F][FONT=Courier]In[/FONT][/COLOR][COLOR=#333333][FONT=Courier] Sheets("Summary").Range("C5:lRow")[/FONT][/COLOR]
[COLOR=#333333][FONT=Courier]        Sheets("Template").Copy After:=Sheets(Sheets.Count)[/FONT][/COLOR]
[COLOR=#00007F][FONT=Courier]With[/FONT][/COLOR][COLOR=#333333][FONT=Courier] c[/FONT][/COLOR]
[COLOR=#333333][FONT=Courier]            ActiveSheet.Name = .Value[/FONT][/COLOR]
[COLOR=#333333][FONT=Courier]            .Parent.Hyperlinks.Add Anchor:=c, Address:="", SubAddress:= _[/FONT][/COLOR]
[COLOR=#333333][FONT=Courier]                "'" & .Text & "'!A1", TextToDisplay:=.Text[/FONT][/COLOR]
[COLOR=#00007F][FONT=Courier]End[/FONT][/COLOR][COLOR=#00007F][FONT=Courier]With[/FONT][/COLOR]
[COLOR=#00007F][FONT=Courier]Next[/FONT][/COLOR][COLOR=#333333][FONT=Courier] c[/FONT][/COLOR]
[COLOR=#333333][FONT=Courier]    Application.ScreenUpdating = [/FONT][/COLOR][COLOR=#00007F][FONT=Courier]True[/FONT][/COLOR]
[COLOR=#00007F][FONT=Courier]End[/FONT][/COLOR][COLOR=#00007F][FONT=Courier]Sub[/FONT][/COLOR]




Any help would be appreciated
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
In Excel, 'pages' refer to bolcks of data that will output on a printer as a 'page'. The tabbed segments in a workbook are referred to as sheets. Do you mean sheets or pages?
Code:
Sub CreateAndNameWorksheets()
Dim c As Range, lRow As Long
[COLOR=#FF0000]lRow = Cells(Rows.Count, 3).End(xlUp).Row[/COLOR]
Application.ScreenUpdating = False
    For Each c In Sheets("Summary").Range("C5:[COLOR=#FF0000]C" & lRow)[/COLOR]
        Sheets("Template").Copy After:=Sheets(Sheets.Count)
        With c
            ActiveSheet.Name = .Value
            .Parent.Hyperlinks.Add Anchor:=c, Address:="", SubAddress:= _
            "'" & .Text & "'!A1", TextToDisplay:=.Text
        EndWith
    Next c
Application.ScreenUpdating = True
EndSub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,249
Members
452,623
Latest member
Techenthusiast

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top