Help! Question about Worksheets.Copy

B

bigfatdummy

All the the code works except I need the new sheets to be copied from
the sheet named template. Here is the code.

Sub add_sheets()

Dim wks As Worksheet
Dim rng As Range
Dim LastRow As Long
Dim I As Long

LastRow = Sheets("Summary").Range("A" & Rows.Count).End(xlUp).Row

For I = 1 To LastRow
Set rng = Sheets("Summary").Range("A" & I)
Set wks = Worksheets.Add(After:=Worksheets(Worksheets.Count - 1))
wks.Name = rng.Value
Next I

Sheets("Summary").Select
Range("A1").Select

End Sub

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

I tried this but it doesnt work.

Sub add_sheets_test()

Dim wks As Worksheet
Dim rng As Range
Dim LastRow As Long
Dim I As Long

LastRow = Sheets("Summary").Range("A" & Rows.Count).End(xlUp).Row

For I = 1 To LastRow
Set rng = Sheets("Summary").Range("A" & I)
Set wks =
Worksheets("Template").Copy(After:=Worksheets(Worksheets.Count - 1))
wks.Name = rng.Value
Next I

Sheets("Summary").Select
Range("A1").Select

End Sub

Any suggestions?
 
T

Tom Ogilvy

Sub add_sheets()

Dim wks As Worksheet
Dim rng As Range
Dim LastRow As Long
Dim I As Long

LastRow = Sheets("Summary").Range("A" & Rows.Count).End(xlUp).Row

For I = 1 To LastRow
Set rng = Sheets("Summary").Range("A" & I)
Worksheets("Master").Copy After:=Worksheets(Worksheets.Count - 1)
set wks = ActiveSheet
wks.Name = rng.Value
Next I

Sheets("Summary").Select
Range("A1").Select

End Sub

--
Regards,
Tom Ogilvy


"bigfatdummy" <[email protected]>
wrote in message
news:[email protected]...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top