Bonjour cher forum,
J'aimerais si possible mettre un nombre égal de caractère à ce code; c'est-à-dire; pour un critère, ça sera 4 chiffres max, etc.
Ce code se trouve dans un userform et mets bien une barrière au bout du nombre max, mais pas de min, et si possible ajouter un msgBox
Private Sub CommandButton1_Click()
For Each Ctl In Me.Controls
If Ctl.Name Like "Cri_*" Then
If Ctl.MaxLength > 0 _
Then Ctl.Text = Left(Ctl.Text, Ctl.MaxLength)
Range(Ctl.ControlTipText) = Ctl.Text
End If
Next
End Sub
Je lui fais bien dire qu'il y a un max mais pas un minimum, ça serait un code de ce type mais je ne sais pas comment je peux modifier le paramètre "MaxLength" :
With Selection.Validation
.Delete
.Add Type:=xlValidateTextLength, AlertStyle:=xlValidAlertStop, _
Operator:=xlEqual, Formula1:="4"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = "Erreur"
.InputMessage = ""
.ErrorMessage = "Veuillez saisir 4 chiffres."
.ShowInput = True
.ShowError = True
End With
Merci pour votre aide