Adding a new sheet (no focus)

  • Thread starter Thread starter SOS
  • Start date Start date
S

SOS

Hi all,

I have a workbook with a sheet called "Master" and I am using th
following line of code to add a new sheet called "Test" (if "Test" doe
not already exist) :

Sheets.Add.Name = "Test"

Is it possible to add this new sheet WITHOUT Excel automatically makin
that the active sheet.

TIA

Seamu
 
Hi Seamus

Don't think so. Here's a workaround:

Sub test()
Dim S As Worksheet, T As Worksheet
Set S = ActiveSheet
On Error Resume Next
Application.ScreenUpdating = False
Set T = Sheets.Add
T.Name = "Test"
T.Move after:=Worksheets(ActiveWorkbook.Worksheets.Count)
S.Activate
Application.ScreenUpdating = True
End Sub

HTH. best wishes Harald
 

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

Back
Top