Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 50
Default Allow Auto Filter Within Macro in Excel 2003 (SP2)

I have the following macro which asks the user for a password and then
passwords all sheets within a workbook which works exactly as I want.

Dim WS As Worksheet
For Each WS In ActiveWorkbook.Worksheets
If WS.ProtectContents = True Then
Title = "Sheet already Protected"
Style = vbCritical
Message = WS.Name & " already protected"
MsgBox Message, Style, Title
E = E + 1
Else
Title = "Doing Protection"
Style = vbInformation
Message = WS.Name & " protected"
MsgBox Message, Style, Title
WS.Protect (PasswordEntered)

End If

However, I have now discovered that I need to allow Auto Filter and have
inserted the following line just before the ENDIF:-

WS.EnableAutoFilter = True

Unfortunately once the macro has run, the Auto Filter option is not showing
the showing.

I have tried to manually protect the sheets using Tools, Protecting, Protect
Sheet and selected Use AutoFilter and I get the desired effect.

What do I need to do to enable the macro to work properly?

  #2   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 11,123
Default Allow Auto Filter Within Macro in Excel 2003 (SP2)

You can use it in the protect line

WS.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFiltering:=True

Or see
http://www.contextures.com/xlautofilter03.html#Protect



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Pank" wrote in message ...
I have the following macro which asks the user for a password and then
passwords all sheets within a workbook which works exactly as I want.

Dim WS As Worksheet
For Each WS In ActiveWorkbook.Worksheets
If WS.ProtectContents = True Then
Title = "Sheet already Protected"
Style = vbCritical
Message = WS.Name & " already protected"
MsgBox Message, Style, Title
E = E + 1
Else
Title = "Doing Protection"
Style = vbInformation
Message = WS.Name & " protected"
MsgBox Message, Style, Title
WS.Protect (PasswordEntered)

End If

However, I have now discovered that I need to allow Auto Filter and have
inserted the following line just before the ENDIF:-

WS.EnableAutoFilter = True

Unfortunately once the macro has run, the Auto Filter option is not showing
the showing.

I have tried to manually protect the sheets using Tools, Protecting, Protect
Sheet and selected Use AutoFilter and I get the desired effect.

What do I need to do to enable the macro to work properly?

  #3   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 50
Default Allow Auto Filter Within Macro in Excel 2003 (SP2)

Ron,

Firstly, Thank U for your valuable input, I will try it out.

Secondly, sorry for the delay in 'saying Thank you', I have just got back to
work from a week on the sick.


"Ron de Bruin" wrote:

You can use it in the protect line

WS.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFiltering:=True

Or see
http://www.contextures.com/xlautofilter03.html#Protect



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Pank" wrote in message ...
I have the following macro which asks the user for a password and then
passwords all sheets within a workbook which works exactly as I want.

Dim WS As Worksheet
For Each WS In ActiveWorkbook.Worksheets
If WS.ProtectContents = True Then
Title = "Sheet already Protected"
Style = vbCritical
Message = WS.Name & " already protected"
MsgBox Message, Style, Title
E = E + 1
Else
Title = "Doing Protection"
Style = vbInformation
Message = WS.Name & " protected"
MsgBox Message, Style, Title
WS.Protect (PasswordEntered)

End If

However, I have now discovered that I need to allow Auto Filter and have
inserted the following line just before the ENDIF:-

WS.EnableAutoFilter = True

Unfortunately once the macro has run, the Auto Filter option is not showing
the showing.

I have tried to manually protect the sheets using Tools, Protecting, Protect
Sheet and selected Use AutoFilter and I get the desired effect.

What do I need to do to enable the macro to work properly?


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
auto filter within a macro Sean Excel Discussion (Misc queries) 4 March 27th 08 11:04 AM
Auto filter run from a macro will not do the same as when done manually. ChemicalJasper Excel Discussion (Misc queries) 0 February 2nd 07 03:25 PM
Auto filter run from a macro will not do the same as when done manually. ChemicalJasper Excel Discussion (Misc queries) 0 February 2nd 07 03:25 PM
Auto Filter Macro Snakeoids Excel Discussion (Misc queries) 10 August 24th 05 08:46 PM
Why can't my macro use Auto Filter when I told the Sheet Protecti. KC Rippstein Excel Worksheet Functions 1 October 28th 04 06:13 PM


All times are GMT +1. The time now is 03:23 AM.

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

About Us

"It's about Microsoft Excel"