Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default adding worksheet with macro but need to get back to 1st sheet

I have a macro adding a worksheet to a workbook. I am using:

ActiveWorkbook.Sheets.Add after:=Worksheets(Worksheets.Count)

I then need to "get back" to the first sheet to make it active -
problem is I cannot reference it by its name - the name on the first
sheet will change each time I use this workbook.

Any help would be greatly appreciated

Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 695
Default adding worksheet with macro but need to get back to 1st sheet

sheets(1).select

" skrev:

I have a macro adding a worksheet to a workbook. I am using:

ActiveWorkbook.Sheets.Add after:=Worksheets(Worksheets.Count)

I then need to "get back" to the first sheet to make it active -
problem is I cannot reference it by its name - the name on the first
sheet will change each time I use this workbook.

Any help would be greatly appreciated

Thanks in advance.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default adding worksheet with macro but need to get back to 1st sheet

Maybe

Dim OldSht As Worksheet
Set OldSht = ActiveSheet ' or Sheets("Sheet1")
ActiveWorkbook.Sheets.Add after:=Worksheets(Worksheets.Count)
OldSht.Activate

VBA Noob


On 13 Dec, 21:29, wrote:
I have a macro adding a worksheet to a workbook. I am using:

ActiveWorkbook.Sheets.Add after:=Worksheets(Worksheets.Count)

I then need to "get back" to the first sheet to make it active -
problem is I cannot reference it by its name - the name on the first
sheet will change each time I use this workbook.

Any help would be greatly appreciated

Thanks in advance.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default adding worksheet with macro but need to get back to 1st sheet

On Dec 13, 4:36 pm, excelent
wrote:
sheets(1).select

" skrev:



I have a macro adding a worksheet to a workbook. I am using:


ActiveWorkbook.Sheets.Add after:=Worksheets(Worksheets.Count)


I then need to "get back" to the first sheet to make it active -
problem is I cannot reference it by its name - the name on the first
sheet will change each time I use this workbook.


Any help would be greatly appreciated


Thanks in advance.- Hide quoted text -


- Show quoted text -


How would this work if it was different workbooks ? The sheet
examples worked great
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default adding worksheet with macro but need to get back to 1st sheet

Sub return_to()
Dim oldsheet As Worksheet
Set oldsheet = ActiveSheet
ActiveWorkbook.Sheets.Add after:=Worksheets(Worksheets.Count)
oldsheet.Select
End Sub


Gord Dibben MS Excel MVP

On Thu, 13 Dec 2007 13:29:48 -0800 (PST),
wrote:

I have a macro adding a worksheet to a workbook. I am using:

ActiveWorkbook.Sheets.Add after:=Worksheets(Worksheets.Count)

I then need to "get back" to the first sheet to make it active -
problem is I cannot reference it by its name - the name on the first
sheet will change each time I use this workbook.

Any help would be greatly appreciated

Thanks in advance.


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
Macro to go back to last used sheet johan Excel Programming 1 July 11th 07 07:44 AM
copy back macro/roll back moh Excel Worksheet Functions 4 March 5th 07 02:19 PM
Macro to prevent adding sheet in a workbook. [email protected] Excel Programming 6 August 15th 06 03:49 AM
Adding new sheet problem-Macro pikapika13[_2_] Excel Programming 2 March 28th 06 04:58 PM
macro adding formula to new sheet toddsavage100 Excel Discussion (Misc queries) 2 March 14th 06 03:03 AM


All times are GMT +1. The time now is 08:44 PM.

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

About Us

"It's about Microsoft Excel"