Copy hidden worksheet

P

Porky79

Hi - trying to modify the below code to copy (ref: Tom Ogilvy) a
hidden worksheet called TEMPLATE but rather than copy to front of the
worksheet list trying to enter it 1 sheet in (i.e. after an index
page). I have tried changing the Copy Before to Copy After. This
places the copied sheet in teh right location but it is copied as a
hidden sheet.

Sub AddNewSheet()
Worksheets("TEMPLATE").Copy Before:=Worksheets(1)
Worksheets(1).Visible = xlSheetVisible
End Sub


Chen anyone help please?

Thanks
 
N

Nigel

The worksheet copy will not be index 1 if you are placing it after
worksheet(1). Change code to the following.

Sub AddNewSheet()
Worksheets("TEMPLATE").Copy After:=Worksheets(1)
Worksheets(2).Visible = xlSheetVisible
End Sub
 
P

Porky79

Ah I see - Almost there. Copies and creates visable worksheet, but for
some reason then selects the next worksheet as the 'current' or
'active' worksheet. I want the copied sheet to be the active sheet to
prevent any data being incorrectly entered.

Thanks so much for your time

Paul
 
N

Nigel

Sub AddNewSheet()
Worksheets("TEMPLATE").Copy After:=Worksheets(1)
Worksheets(2).Visible = xlSheetVisible
Worksheets(2).Activate
End Sub
 
D

Dave Peterson

Make it visible and then select/activate it:

Sub AddNewSheet()
Worksheets("TEMPLATE").Copy After:=Worksheets(1)
Worksheets(2).Visible = xlSheetVisible
worksheets(2).select '<-- added
End Sub
 

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