Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Auto-Filter When Workbook Protected

To overcome the ListObject(x) you could try this sheet event code assuming
the List range will be fixed.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Const WS_RANGE As String = "A6:K38"
Dim cell As Range

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
Me.Unprotect Password:="justme"
Else
Me.Protect Password:="justme"
End If

ws_exit:
Application.EnableEvents = True
End Sub


Gord

On Wed, 24 Dec 2008 19:09:17 -0800, Gord Dibben <gorddibbATshawDOTca wrote:

I know nothing about Excel on a Mac but a few points to mention.

Did you put the selectionchange event code into the sheet module?

The ListObjects(x) should be (1) if that's the only List you have in the
workbook.

A6:A36 is a range in a single column so cannot possibly be a header row.

Your List header row should be A6:K6

The "solution" you found at the Website requires you to change Sheet1 to
your sheet name and the code goes into Thisworkbook module, not a sheet or
general module.

Private Sub Workbook_Open()
With Sheets("your sheetname")
.Protect Password:="test", DrawingObjects:=True, _
contents:=True, Scenarios:=True, _
userinterfaceonly:=True
.EnableAutoFilter = True
End With
End Sub

But take note: the Autofilter arrows must be applied before the sheet is
protected. You cannot apply after.

If you looked at the macro I originally posted that's what the

line .Range("A1").AutoFilter does for you

Sub auto_filter()
With Sheets("Sheet1")
.Range("A1").AutoFilter
.Protect Password:="justme", userinterfaceonly:=True
.EnableAutoFilter = True
End With
End Sub


Gord

On Wed, 24 Dec 2008 14:22:08 -0800, Neon520
wrote:

Hi Gord,

I'm not sure if it makes any difference or not in this case that I'm using
Office 2004 for Mac. I know that it supports Macro and VBA, except some
codes are different from the Office for Window.

In Office 04, there's actually a List Wizard that help user to generate
list. And you're right. My list is A6:K38 with A6:A36 as Header Row and
A39:K39 as Total Row. When I put your code as you instructed, here is an
error message that I receive:

Run-time error ‘9’:
Subscript out of range

I tried play around with it by changing the Set objlist =
Me.ListObjects(1) << to different number, but nothing really works.

FYI, I did tried a solution found in Office Online Website posted by MS he
http://office.microsoft.com/en-us/ex...982701033.aspx

Private Sub Workbook_Open()
Sheet1.Protect password:="test", DrawingObjects:=True, _
contents:=True, Scenarios:=True, _
userinterfaceonly:=True
Sheet1.EnableAutoFilter = True
End Sub

But it doesn't work at all. Is this because I'm using Office for Mac?

Please explain?

Thanks,
Neon520


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using auto filter after my worksheet is protected LY Excel Worksheet Functions 2 July 28th 08 12:10 PM
Help with using Auto-filter in a protected Worksheet. Ayo Excel Discussion (Misc queries) 5 October 29th 07 04:10 PM
Auto Filter with Protected Worksheet JohnGuts Excel Worksheet Functions 4 April 24th 06 09:14 AM
Auto Filter - Protected sheet/workbook ronwill Excel Discussion (Misc queries) 3 January 10th 06 03:28 PM
how to i use auto filter on a protected worksheet shirley Excel Programming 1 March 2nd 04 11:26 AM


All times are GMT +1. The time now is 06:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"