O
oliv
Guest
je cherche à créer un répertoire en empêchant l'enregistrement d'une même adresse plusieurs fois. Comment m'y prendre ?
merci d'avance
merci d'avance
Private Sub OKbutton_Click()
Dim action As Boolean
Dim numdossard As Integer
Dim i As Integer
Dim numtemps As Variant
If saisie.Dossard.Text = '' Or saisie.Temps.Text = '' Then
GoTo fin
End If
numdossard = saisie.Dossard.Text
numtemps = saisie.Temps.Text
action = False
For i = 1 To 500 Step 1
If Cells(i + 2, 1) = numdossard Then
If Cells(i + 2, 9) <> 'NA' Then
saisie.Hide
MsgBox ('ATTENTION, un temps a déjà été enregistré')
Rows(i + 2).Select
action = True
Exit For
End If
If Cells(i + 2, 9) = 'NA' Then
Cells(i + 2, 9) = numtemps
Cells(i + 2, 9).Select
saisie.Dossard.Text = ''
saisie.Temps.Text = ''
saisie.Dossard.SetFocus
tempsprec = numtemps
dossardprec = numdossard
action = True
Exit For
End If
End If
Next i
If action = False Then
saisie.Hide
MsgBox ('Le dossard n'a pas été enregistré')
End If
fin:
End Sub