'définit les variables début, nLigneTxt, n,f
'quand on ne met pas "as ...." de quel type sont les variables?
Dim début, nLigneTxt, n, f
'initilisation du userform
Private Sub UserForm_Initialize()
'on définit f qui est la feuille "BD"
Set f = Sheets("BD")
'la variable début équivaut au chiffre 1
début = 1
'la variable nLigneTxt équivaut au chiffre 5
nLigneTxt = 5
'la variable n équivaut à nLigneTxt c'est a dire à 5
n = nLigneTxt
' on définit nBD qui equivaut au nombre de colonne et après j'ai pas compris...
nBD = Application.CountA(f.[A:A]) - 1
'if le nombre nBD est inférieur à la variable n alors n=nBD
If nBD < n Then n = nBD
'on remonte le scrollbar en haut
Me.ScrollBar1.Min = 1
'ça j'ai pas trop compris
Me.ScrollBar1.Max = nBD - n + 1
'on va au sub affiche
affiche
'fin de la maccro
End Sub
'début de la variable
Sub affiche()
'pour la variable i equivalant à 1 jusqu'a le chiffre défini par la variable n
For i = 1 To n
'on défini le texte selon la cellule définit par la variable i + début en ligne 1 de la feuille BD
Me("txt1" & i).Value = f.Cells(i + début, 1)
jusque la c'est bon?
Me("txt2" & i).Value = f.Cells(i + début, 2)
Me("txt3" & i).Value = f.Cells(i + début, 3)
If i Mod 2 = 0 Then
Me("txt1" & i).BackColor = RGB(0, 255, 0)
Me("txt2" & i).BackColor = RGB(0, 255, 0)
Me("txt3" & i).BackColor = RGB(0, 255, 0)
End If
Next i
Me.Repaint
End Sub
Private Sub ScrollBar1_Change()
début = ScrollBar1
affiche
End Sub
Private Sub B_ok_Click()
Set f = Sheets("BD")
f.[K2] = "*" & Me.TextBox1 & "*"
f.[A1:C10000].AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=f.[K1:K2], CopyToRange:=Sheets("interro").[A1:C1]
Set f = Sheets("interro")
début = 1
For i = 1 To n
Me("txt1" & i).Value = ""
Me("txt2" & i).Value = ""
Me("txt3" & i).Value = ""
Next i
nInterro = Application.CountA(f.[A:A]) - 1
If nInterro < n Then n = nInterro
Me.ScrollBar1.Min = 1
Me.ScrollBar1.Max = nInterro - n + 1
affiche
n = nLigneTxt
End Sub