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

  • Thread starter Thread starter dennis.mccarthy
  • Start date Start date
D

dennis.mccarthy

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.
 
Maybe

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

VBA Noob
 
sheets(1).select

"(e-mail address removed)" skrev:








- Show quoted text -

How would this work if it was different workbooks ? The sheet
examples worked great
 
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
 
Back
Top