MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Previous Worksheet

Posted by Paul Magruder on December 20, 2000 4:10 AM

Can you please tell me the code used to go to the worksheet to the left of the active worksheet. I need to activate the sheet without refering to the sheets name, because the name will change each time I run the Macro. (I am using the macro to insert a new sheet and name it).
I am using Excel 97.

Thanks in Advance
Paul Magruder

Posted by Celia on December 20, 2000 5:31 AM

Dim X%, y%
X = Worksheets.Count
For y = 2 To X
If Worksheets(y) Is ActiveSheet Then
Worksheets(y - 1).Activate
Exit For
End If

Posted by JAF on December 20, 2000 6:11 AM

You can also use the following:

Sub select_previous()
On Error Resume Next
End Sub