Bonjour Cousinhub,
Merci pour ta réponse :)
Tu définis :
Dim RechercheVisa As Range
Et tu recherches un "String"...
Effectivement
Avec RechercheVisa en "String" et Set devant, j'ai une erreur "Object requis" sur cette ligne concernant RechercheVisa :
Set RechercheVisa = Sheets("BD").Range("M2:M" & dl).Find(what:=UtilisateurActuel, LookIn:=xlValues, lookat:=xlWhole)
Sans le Set devant RechercheVisa, j'ai une erreur "Qualificateur incorrect" sur cette ligne concernant RechercheVisa également :
strAdresse = RechercheVisa.Address
J'ai donc tenté de récupérer l'adresse de mon .find comme ceci :
Sub ControlVisa()
Dim dl As Long
Dim RechercheVisa As String
Dim StatutVisa As String
Dim UtilisateurActuel As String
Dim Adresse As Range
dl = Sheets("BD").Range("M" & Rows.Count).End(xlUp).Row
UtilisateurActuel = UCase(Environ("username"))
RechercheVisa = Sheets("BD").Range("M2:M" & dl).Find(What:=UtilisateurActuel, LookIn:=xlValues, LookAt:=xlWhole)
Set Adresse = Sheets("BD").Range("M2:M" & dl).Find(What:=UtilisateurActuel, LookIn:=xlValues, LookAt:=xlWhole).Address
StatutVisa = Adresse.Offset(0, 1).Value
If Not RechercheVisa Is Nothing Then 'condition : s'il existe au moins une occurrence trouvée
If StatutVisa = "Oui" Then Exit Sub
If StatutVisa = "Non" Or StatutVisa = "" Then USF_Avertissement.Show
Else:
With Sheets("BD")
.Unprotect "mdp"
.Range("M:" & dl + 1).Value = UCase(Environ("username"))
.Protect "mdp"
End With
End If
End Sub
mais ce coup-ci j'ai une incompatibilité de type sur cette ligne, toujours sur RechercheVisa :
If Not RechercheVisa Is Nothing Then 'condition : s'il existe au moins une occurrence trouvée