ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   New Users to Excel (https://www.excelbanter.com/new-users-excel/)
-   -   Open workbook at a particular sheet (https://www.excelbanter.com/new-users-excel/50592-open-workbook-particular-sheet.html)

George Gee

Open workbook at a particular sheet
 
Hi all.

I have following code in a workbook, it protects all sheets,
and turns on autofilter. (Excel 200).

Private Sub Workbook_Open()
On Error Resume Next
Dim ws As Worksheet
'check for filter, turn on if none exists
For Each ws In ActiveWorkbook.Worksheets
With ws
If Not .AutoFilterMode Then
.Range("").AutoFilter
End If
.EnableAutoFilter = True
.Protect Password:="", _
Contents:=True, UserInterfaceOnly:=True
End With
Next
End Sub


Can I add to this, to always open the workbook at a particular
worksheet, regardless of where it was last closed (saved)?
Any help with this code much appreciated.

Many thanks

George Gee



Bob Phillips

Private Sub Workbook_Open()
On Error Resume Next
Dim ws As Worksheet
'check for filter, turn on if none exists
For Each ws In ActiveWorkbook.Worksheets
With ws
If Not .AutoFilterMode Then
.Range("").AutoFilter
End If
.EnableAutoFilter = True
.Protect Password:="", _
Contents:=True, UserInterfaceOnly:=True
End With
Next
Worksheets("Sheet1").Activate
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"George Gee" wrote in message
...
Hi all.

I have following code in a workbook, it protects all sheets,
and turns on autofilter. (Excel 200).

Private Sub Workbook_Open()
On Error Resume Next
Dim ws As Worksheet
'check for filter, turn on if none exists
For Each ws In ActiveWorkbook.Worksheets
With ws
If Not .AutoFilterMode Then
.Range("").AutoFilter
End If
.EnableAutoFilter = True
.Protect Password:="", _
Contents:=True, UserInterfaceOnly:=True
End With
Next
End Sub


Can I add to this, to always open the workbook at a particular
worksheet, regardless of where it was last closed (saved)?
Any help with this code much appreciated.

Many thanks

George Gee





George Gee

Many thanks Bob, that's perfect.

George Gee

Bob Phillips wrote:
Private Sub Workbook_Open()
On Error Resume Next
Dim ws As Worksheet
'check for filter, turn on if none exists
For Each ws In ActiveWorkbook.Worksheets
With ws
If Not .AutoFilterMode Then
.Range("").AutoFilter
End If
.EnableAutoFilter = True
.Protect Password:="", _
Contents:=True, UserInterfaceOnly:=True
End With
Next
Worksheets("Home").Activate
End Sub



"George Gee" wrote in message
...
Hi all.

I have following code in a workbook, it protects all sheets,
and turns on autofilter. (Excel 200).

Private Sub Workbook_Open()
On Error Resume Next
Dim ws As Worksheet
'check for filter, turn on if none exists
For Each ws In ActiveWorkbook.Worksheets
With ws
If Not .AutoFilterMode Then
.Range("").AutoFilter
End If
.EnableAutoFilter = True
.Protect Password:="", _
Contents:=True, UserInterfaceOnly:=True
End With
Next
End Sub


Can I add to this, to always open the workbook at a particular
worksheet, regardless of where it was last closed (saved)?
Any help with this code much appreciated.

Many thanks

George Gee





All times are GMT +1. The time now is 09:15 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com