Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Activate Previous worksheet after adding a new worksheet

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?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Activate Previous worksheet after adding a new worksheet

dim mySelection as range
set myselection = selection
'add your worksheet
application.goto myselection



wrote:

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?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default Activate Previous worksheet after adding a new worksheet

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default Activate Previous worksheet after adding a new worksheet

I think this should work:

Option Explicit

Sub ()
Dim CurrentSheet, NewSheet As Worksheet

Set CurrentSheet = ActiveSheet
Set NewSheet = Worksheets.Add

CurrentSheet.Activate
End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
reference cell from previous worksheet without "naming" worksheet Kristin Excel Worksheet Functions 3 August 20th 07 08:30 PM
Activate Worksheet cottage6 Excel Programming 1 April 21st 05 06:46 PM
Worksheet.activate Jeff Excel Discussion (Misc queries) 1 December 14th 04 01:52 PM
Return to previous worksheet after code pastes in another worksheet? Ron[_28_] Excel Programming 4 September 4th 04 07:52 PM
Worksheet activate Lee Hunter[_2_] Excel Programming 2 August 25th 04 05:55 PM


All times are GMT +1. The time now is 06:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"