PC Review


Reply
Thread Tools Rate Thread

adding worksheet with macro but need to get back to 1st sheet

 
 
dennis.mccarthy@us.atlascopco.com
Guest
Posts: n/a
 
      13th Dec 2007
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 With Quote
 
 
 
 
excelent
Guest
Posts: n/a
 
      13th Dec 2007
sheets(1).select

"(E-Mail Removed)" 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.
>

 
Reply With Quote
 
VBA Noob
Guest
Posts: n/a
 
      13th Dec 2007
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, dennis.mccar...@us.atlascopco.com 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 With Quote
 
dennis.mccarthy@us.atlascopco.com
Guest
Posts: n/a
 
      13th Dec 2007
On Dec 13, 4:36 pm, excelent <excel...@discussions.microsoft.com>
wrote:
> sheets(1).select
>
> "dennis.mccar...@us.atlascopco.com" 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
 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      13th Dec 2007
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), (E-Mail Removed)
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hide worksheet when moving back to another sheet Johanna Gronlund Microsoft Excel Programming 2 1st Feb 2010 02:33 PM
Macro to go back to last used sheet johan Microsoft Excel Programming 1 11th Jul 2007 07:44 AM
Get macro to run on any worksheet without renaming the sheet? =?Utf-8?B?QW5kcmV3IEI=?= Microsoft Excel Misc 6 26th Jul 2006 03:03 AM
Go back to previously viewing worksheet using macro =?Utf-8?B?R29l?= Microsoft Excel Programming 2 11th Mar 2004 03:51 AM
Re: Adding worksheet using macro Chip Pearson Microsoft Excel Worksheet Functions 0 28th Jul 2003 01:57 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:01 AM.