1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
| Option Explicit
Function VerifMDP(Utilisateur As String, MdP As String) As Long
Dim rngTrouve As Range
VerifMDP = False 'par défaut, renvoie FAUX
Dim L As Long
L = SerchXls(Sheets("parametrage").Range("a:a"), Sheets("parametrage").Range("a1"), Utilisateur, True, False)
If L = 0 Then Exit Function
If Sheets("parametrage").Cells(L, 2) <> MdP Then Exit Function
VerifMDP = L
'With Sheets("parametrage") 'dans la feuille paramétrage
' 'cherche, colonne A, le nom d'utilisateur saisi
' Set rngTrouve = .Columns(1).Cells.Find(Utilisateur, LookAt:=xlWhole)
' If rngTrouve Is Nothing Then 'si il ne trouve pas
' VerifMDP = False 'la fonction renvoie faux
' Else 's'il le trouve
' 'vérifie que le mot saisi feuille parametrgae colonne B = mdp entré
' If rngTrouve.Offset(0, 1) <> MdP Then
' VerifMDP = False 'si FAUX
' Else
' VerifMDP = True 'si VRAI
' End If
' End If
'End With
End Function
Function SerchXls(Myrange As Range, MyCellule As Range, strRecherche, EntierCell As Boolean, EnBoucle As Boolean) As Long '
Dim Entier As String
On Error Resume Next
SerchXls = 0
If EntierCell = False Then Entier = xlPart Else Entier = xlWhole
SerchXls = Myrange.Cells.Find(What:=strRecherche, After:=MyCellule, LookIn:=xlFormulas, LookAt _
:=Entier, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=EntierCell).Row
If SerchXls <= MyCellule.Row And EnBoucle = False Then SerchXls = 0
End Function
Sub AfficheFeuilles(L As Long)
ActiveSheet.Unprotect
Dim Col As Byte, i As Byte, Lig As Integer
If UCase(Sheets("parametrage").Cells(L, 3).Value) = "X" Then Sheets("parametrage").Visible = True Else Sheets("parametrage").Visible = False
For i = 4 To Sheets("parametrage").UsedRange.Columns.Count
If Trim("" & Sheets("parametrage").Cells(1, i)) <> "" Then
If UCase(Sheets("parametrage").Cells(L, i).Value) = "X" Then
Range(Sheets("parametrage").Cells(1, i)).EntireColumn.Locked = False
Else
Range(Sheets("parametrage").Cells(1, i).Value).EntireColumn.Locked = True
End If
End If
Next
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
'With Sheets("parametrage") 'dans la feuille paramétrage
'
' 'comme on va boucler de la colonne 3 à la dernière colonne, on stocke le n° de la dern colonne :
' Col = .Cells(1, .Cells.Columns.Count).End(xlToLeft).Column
'
' 'on cherche colonne A le nom d'utilisateur saisi et on stocke son num de ligne
' Lig = .Columns(1).Cells.Find(Utilisateur, LookAt:=xlWhole).Row
'
'
' For i = 3 To Col
' If UCase(.Cells(Lig, i)) = "X" Then 'si on trouve un "X" dans la cellule
'
'
'
' Sheets(.Cells(1, i).Value).Visible = True 'on affiche la feuille
'
' Sheets("BASE").Range(.Cells(1, i).Value & "1").EntireColumn.Locked = True 'on deverouille
' 'Sheets("BASE").Select.Columns(.Cells(1, i).Value).Locked = True 'on deverouille
'
' Else
' Sheets(.Cells(1, i).Value).Visible = xlSheetVeryHidden 'sinon on la masque
'
' Sheets("BASE").Range(.Cells(1, i).Value & "1").EntireColumn.Locked = False 'sinon on verouille
' 'Sheets("BASE").Select.Columns(.Cells(1, i).Value).Locked = False 'on deverouille
'
'
'
'
'
'
' End If
' Next i
'End With
End Sub |
Partager