stop added worksheet becoming active

  • Thread starter Thread starter crichardson
  • Start date Start date
C

crichardson

I have a spreadsheet application where I want to create sheet fro
within vba code. I can do this easily of course but I don't wan
Excel to make a newly added worksheet active - I just want the shee
adding while remaining on the worksheet that happened to be active whe
the new sheet is added.

I've tried Application.ScreenUpdating but this doesn't have any effect
Here's how I'm adding a new sheet...

Worksheets.Add
Worksheets.Application.ActiveSheet.Name = sheetname

Thanks in advance.

Cliv
 
Hi clive
try something like the following
sub foo()
dim wks_old as worksheet
Dim sheetname
application.screenupdating = false
set wks_old = activesheet
'...
sheetname = "mynewnonactivesheet"
Worksheets.Add
Worksheets.Application.ActiveSheet.Name = sheetname
wks_old.activate
application.screenupdating = True
end sub
 
Dim sh as Worksheet
application.ScreenUpdating = False
set sh = Activesheet
Worksheets.Add
ActiveSheet.Name = sheetname
sh.Activate
Application.ScreenUpdating = True
 

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