OVH Cloud OVH Cloud

Macro tri sur feuille protégée

5 réponses
Avatar
Pierre CFI [mvp]
Bonjour

bizarre, bizarre
sur une feuille protégee par un mot de passe, avec un filtre automatique
je fais à l'ouverture du classeur
Feuil4.EnableAutoFilter = True
Feuil4.Protect Contents:=True, UserInterfaceOnly:=True
bon, le filtre est actif, et la feuille protégée Mais si je lance une macro de tri (macro faite avec l'enregistreur) , la macro, non
seulement s'exécute, mais déprotége ma feuille ?????

--
Pierre CFI
MVP Microsoft Access
Mail : http://cerbermail.com/?z0SN8cN53B

Site pour bien commencer
http://users.skynet.be/mpfa/
Site perso
http://access.cfi.free.fr

5 réponses

Avatar
Pierre CFI [mvp]
suite
donc sur une feuille protégée, méme sans mettre le filtre automatique avec
Sub Macro1()
'
' Macro1 Macro
' Macro enregistrée le 29/11/2003 par Pierre SALAUN
'
ActiveSheet.EnableAutoFilter = True
ActiveSheet.Cells(1, ActiveCell.Column).Select
Selection.Sort Key1:¬tiveSheet.Cells(1, ActiveCell.Column), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:úlse, Orientation:=xlTopToBottom
ActiveSheet.Protect Contents:=True, UserInterfaceOnly:=True

End Sub
on peut trier, mais je viens peut etre de reinventer le vin chaud :o))
et jps que j'ai pas lu depuis longtemps me le dira

--
Pierre CFI
MVP Microsoft Access
Mail : http://cerbermail.com/?z0SN8cN53B

Site pour bien commencer
http://users.skynet.be/mpfa/
Site perso
http://access.cfi.free.fr
"Pierre CFI [mvp]" a écrit dans le message de news:
Bonjour

bizarre, bizarre
sur une feuille protégee par un mot de passe, avec un filtre automatique
je fais à l'ouverture du classeur
Feuil4.EnableAutoFilter = True
Feuil4.Protect Contents:=True, UserInterfaceOnly:=True
bon, le filtre est actif, et la feuille protégée Mais si je lance une macro de tri (macro faite avec l'enregistreur) , la macro,
non

seulement s'exécute, mais déprotége ma feuille ?????

--
Pierre CFI
MVP Microsoft Access
Mail : http://cerbermail.com/?z0SN8cN53B

Site pour bien commencer
http://users.skynet.be/mpfa/
Site perso
http://access.cfi.free.fr




Avatar
Pierre CFI [mvp]
bon, je continue mon numéro
en affectant ces macros à des boutons persos, on peut trier ou filtrer une feuille protégée

Sub FiltreAuto()
Dim R As Range
Set R = ActiveSheet.Cells(1, ActiveCell.Column)
If ActiveSheet.ProtectContents Then
ActiveSheet.Protect contents:=True, UserInterfaceOnly:=True
R.Select
Selection.AutoFilter
Else
Selection.AutoFilter
End If
End Sub
Sub TriCroissant()
Dim R As Range
Set R = ActiveSheet.Cells(1, ActiveCell.Column)
If ActiveSheet.ProtectContents Then
ActiveSheet.Protect contents:=True, UserInterfaceOnly:=True
R.Select
Selection.Sort Key1:=R, Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:úlse, Orientation:=xlTopToBottom
ActiveSheet.Protect contents:=True, UserInterfaceOnly:=True
Else
R.Select
Selection.Sort Key1:=R, Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:úlse, Orientation:=xlTopToBottom
End If

End Sub

Sub TriDécroissant()
Dim R As Range
Set R = ActiveSheet.Cells(1, ActiveCell.Column)
If ActiveSheet.ProtectContents Then
ActiveSheet.Protect contents:=True, UserInterfaceOnly:=True
R.Select
Selection.Sort Key1:=R, Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:úlse, Orientation:=xlTopToBottom
ActiveSheet.Protect contents:=True, UserInterfaceOnly:=True
Else
R.Select
Selection.Sort Key1:=R, Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:úlse, Orientation:=xlTopToBottom
End If
End Sub


--
Pierre CFI



Avatar
FxM
Bonjour Pierre,

Idée bête que je préfère donc dire moi-même ;o)
- déprotéger
- trier
- reprotéger

@+
FxM



Pierre CFI [mvp] wrote:

bon, je continue mon numéro
en affectant ces macros à des boutons persos, on peut trier ou filtrer une feuille protégée

Sub FiltreAuto()
Dim R As Range
Set R = ActiveSheet.Cells(1, ActiveCell.Column)
If ActiveSheet.ProtectContents Then
ActiveSheet.Protect contents:=True, UserInterfaceOnly:=True
R.Select
Selection.AutoFilter
Else
Selection.AutoFilter
End If
End Sub
Sub TriCroissant()
Dim R As Range
Set R = ActiveSheet.Cells(1, ActiveCell.Column)
If ActiveSheet.ProtectContents Then
ActiveSheet.Protect contents:=True, UserInterfaceOnly:=True
R.Select
Selection.Sort Key1:=R, Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:úlse, Orientation:=xlTopToBottom
ActiveSheet.Protect contents:=True, UserInterfaceOnly:=True
Else
R.Select
Selection.Sort Key1:=R, Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:úlse, Orientation:=xlTopToBottom
End If

End Sub

Sub TriDécroissant()
Dim R As Range
Set R = ActiveSheet.Cells(1, ActiveCell.Column)
If ActiveSheet.ProtectContents Then
ActiveSheet.Protect contents:=True, UserInterfaceOnly:=True
R.Select
Selection.Sort Key1:=R, Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:úlse, Orientation:=xlTopToBottom
ActiveSheet.Protect contents:=True, UserInterfaceOnly:=True
Else
R.Select
Selection.Sort Key1:=R, Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:úlse, Orientation:=xlTopToBottom
End If
End Sub


--
Pierre CFI





Avatar
Pierre CFI [mvp]
.../...
bien sur, mais ici l'utilisateur ne connait pas le mot dz passe (et ne vient pas ici pour qu'on lui donne)

--
Pierre CFI
MVP Microsoft Access
Mail : http://cerbermail.com/?z0SN8cN53B

Site pour bien commencer
http://users.skynet.be/mpfa/
Site perso
http://access.cfi.free.fr
"FxM" a écrit dans le message de news:
Bonjour Pierre,

Idée bête que je préfère donc dire moi-même ;o)
- déprotéger
- trier
- reprotéger

@+
FxM



Pierre CFI [mvp] wrote:

bon, je continue mon numéro
en affectant ces macros à des boutons persos, on peut trier ou filtrer une feuille protégée

Sub FiltreAuto()
Dim R As Range
Set R = ActiveSheet.Cells(1, ActiveCell.Column)
If ActiveSheet.ProtectContents Then
ActiveSheet.Protect contents:=True, UserInterfaceOnly:=True
R.Select
Selection.AutoFilter
Else
Selection.AutoFilter
End If
End Sub
Sub TriCroissant()
Dim R As Range
Set R = ActiveSheet.Cells(1, ActiveCell.Column)
If ActiveSheet.ProtectContents Then
ActiveSheet.Protect contents:=True, UserInterfaceOnly:=True
R.Select
Selection.Sort Key1:=R, Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:úlse, Orientation:=xlTopToBottom
ActiveSheet.Protect contents:=True, UserInterfaceOnly:=True
Else
R.Select
Selection.Sort Key1:=R, Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:úlse, Orientation:=xlTopToBottom
End If

End Sub

Sub TriDécroissant()
Dim R As Range
Set R = ActiveSheet.Cells(1, ActiveCell.Column)
If ActiveSheet.ProtectContents Then
ActiveSheet.Protect contents:=True, UserInterfaceOnly:=True
R.Select
Selection.Sort Key1:=R, Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:úlse, Orientation:=xlTopToBottom
ActiveSheet.Protect contents:=True, UserInterfaceOnly:=True
Else
R.Select
Selection.Sort Key1:=R, Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:úlse, Orientation:=xlTopToBottom
End If
End Sub


--
Pierre CFI








Avatar
FxM
J'ai bien fait de la poser moi-même ;o)

@+
FxM

Pierre CFI [mvp] wrote:

.../...
bien sur, mais ici l'utilisateur ne connait pas le mot dz passe (et ne vient pas ici pour qu'on lui donne)

--
Pierre CFI
MVP Microsoft Access
Mail : http://cerbermail.com/?z0SN8cN53B

Site pour bien commencer
http://users.skynet.be/mpfa/
Site perso
http://access.cfi.free.fr
"FxM" a écrit dans le message de news:

Bonjour Pierre,

Idée bête que je préfère donc dire moi-même ;o)
- déprotéger
- trier
- reprotéger

@+
FxM



Pierre CFI [mvp] wrote:


bon, je continue mon numéro
en affectant ces macros à des boutons persos, on peut trier ou filtrer une feuille protégée

Sub FiltreAuto()
Dim R As Range
Set R = ActiveSheet.Cells(1, ActiveCell.Column)
If ActiveSheet.ProtectContents Then
ActiveSheet.Protect contents:=True, UserInterfaceOnly:=True
R.Select
Selection.AutoFilter
Else
Selection.AutoFilter
End If
End Sub
Sub TriCroissant()
Dim R As Range
Set R = ActiveSheet.Cells(1, ActiveCell.Column)
If ActiveSheet.ProtectContents Then
ActiveSheet.Protect contents:=True, UserInterfaceOnly:=True
R.Select
Selection.Sort Key1:=R, Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:úlse, Orientation:=xlTopToBottom
ActiveSheet.Protect contents:=True, UserInterfaceOnly:=True
Else
R.Select
Selection.Sort Key1:=R, Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:úlse, Orientation:=xlTopToBottom
End If

End Sub

Sub TriDécroissant()
Dim R As Range
Set R = ActiveSheet.Cells(1, ActiveCell.Column)
If ActiveSheet.ProtectContents Then
ActiveSheet.Protect contents:=True, UserInterfaceOnly:=True
R.Select
Selection.Sort Key1:=R, Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:úlse, Orientation:=xlTopToBottom
ActiveSheet.Protect contents:=True, UserInterfaceOnly:=True
Else
R.Select
Selection.Sort Key1:=R, Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:úlse, Orientation:=xlTopToBottom
End If
End Sub


--
Pierre CFI