Dim n, dat$(), pos& 'mémorise les variables
Private Sub CommandButton1_Click() '1ère date
Dim premlig&, derlig&, dercol%, i&, j%, d&
n = Int(Abs(Val(TextBox1)))
If n > 10 Then n = 10
TextBox1 = n
premlig = [A:A].Find("EMPLACEMENTS", , xlFormulas).Row
derlig = Cells.Find("*=*", , , , xlByRows, xlPrevious).Row
dercol = ActiveSheet.UsedRange.Columns.Count
For i = premlig + 12 To derlig Step 15
For j = 1 To dercol
If Cells(i, j) = n And IsDate(Cells(i - 12, j)) Then
d = d + 1
ReDim Preserve dat(1 To d)
dat(d) = Cells(i - 12, j).Resize(13).Address
End If
Next
Next
pos = 0
If d = 0 Then MsgBox "Aucune date", , "Somme = " & n: GoTo 1
pos = 1
Application.Goto Range(dat(1)), True
1 TextBox1.SetFocus: TextBox1.SelStart = 0: TextBox1.SelLength = 2
End Sub
Private Sub CommandButton2_Click() 'Suivante
If pos = 0 Then GoTo 1
TextBox1 = n
If pos = UBound(dat) Then pos = 0
pos = pos + 1
Application.Goto Range(dat(pos)), True
1 TextBox1.SetFocus: TextBox1.SelStart = 0: TextBox1.SelLength = 2
End Sub
Private Sub CommandButton3_Click() 'Précédente
If pos = 0 Then GoTo 1
TextBox1 = n
pos = pos - 1
If pos = 0 Then pos = UBound(dat)
Application.Goto Range(dat(pos)), True
1 TextBox1.SetFocus: TextBox1.SelStart = 0: TextBox1.SelLength = 2
End Sub