Activate Previous worksheet after adding a new worksheet

  • Thread starter Thread starter Chingangel
  • Start date Start date
C

Chingangel

I want to activate the worksheet that was active before I added a new
sheet to the workbook in VBA for excel. Can anyone help me on how to do
that?
 
dim mySelection as range
set myselection = selection
'add your worksheet
application.goto myselection
 
Not sure if this post worked so apologies if this is a duplicate:

Option Explicit

Sub ()
Dim CurrentSheet, NewSheet As Worksheet

Set CurrentSheet = ActiveSheet
Set NewSheet = Worksheets.Add

CurrentSheet.Activate
End Sub
 
I think this should work:

Option Explicit

Sub ()
Dim CurrentSheet, NewSheet As Worksheet

Set CurrentSheet = ActiveSheet
Set NewSheet = Worksheets.Add

CurrentSheet.Activate
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

Back
Top