Open workbook at specific worksheet

A

Adam Price

Is it possible to specify a particular worksheet for a workbook to ope
at?

Eg. Open file 'Employee.xls' at worksheet titled 'Dave'

I can't find any relevant switches to specify on startup, but as a sid
note, info on opening position must be recorded within the spreadshee
file as a workbook will always open at the last sheet you were using.

Any help greatly appreciated.

Cheers,
Ada
 
D

Dave Peterson

If you save the file with Dave the active worksheet, it'll reopen that way, too.

Or you could have a macro do the work for you:

Option Explicit
Sub auto_open()
Dim wks As Worksheet

Set wks = Nothing
On Error Resume Next
Set wks = ThisWorkbook.Worksheets("Dave")
On Error GoTo 0

If wks Is Nothing Then
'dave doesn't exist
'what should happen?
Else
Application.Goto wks.Range("a1"), scroll:=True
'or
'wks.select
End If

End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

ps. That is a wonderful name for a worksheet! More people should use it.
 
Top