1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| Option Compare Text
Dim f, ligneEnreg, choix1()
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = 0 Then Cancel = True 'Désactive le bouton FERMER du UserForm
End Sub
Private Sub Imprimer_Click()
Me.PrintForm
End Sub
Private Sub Quitter_Click()
Unload Me
UserForm_Referentiel_doc.Show
End Sub
Private Sub UserForm_Initialize()
Set f = Sheets("Suivi documentaire")
' I correspond à la colonne concernant l'intitulé des documents
choix1 = Application.Transpose(f.Range("I2:I" & f.[I65000].End(xlUp).Row).Value)
Me.ChoixTitre.List = SansDoublons(choix1)
ligneEnreg = f.[I65000].End(xlUp).Row + 1
Me.ChoixTitre.SetFocus
End Sub
Private Sub ChoixTitre_Change()
If Me.ChoixTitre.ListIndex = -1 And IsError(Application.Match(Me.ChoixTitre, choix1, 0)) Then
Me.ChoixTitre.List = Filter(SansDoublons(choix1), Me.ChoixTitre.Text, True, vbTextCompare)
Me.ChoixTitre.DropDown
Else
ChoixTitre_click
End If
End Sub
Private Sub ChoixTitre_click()
'B correspond au type de documents et I aux intitulés
a = f.Range("B2:I" & f.[B65000].End(xlUp).Row).Value
Dim b(): ReDim b(1 To UBound(a))
J = 0
For I = 1 To UBound(a)
If a(I, 2) = Me.ChoixTitre Then J = J + 1: b(J) = a(I, 1)
Next I
ReDim Preserve b(1 To J)
Me.choixType.List = b
Me.choixType.SetFocus
If Val(Application.Version) > 10 Then SendKeys "{f4}"
Me.choixType = ""
raz
End Sub
Private Sub ChoixType_click()
'B correspond au type de documents, "i" aux intitulés et "b" aux types de doc
For I = 2 To f.[B65000].End(xlUp).Row
If f.Cells(I, "i") = Me.ChoixTitre And f.Cells(I, "b") = Me.choixType Then
ligneEnreg = I
For K = 1 To 3
Me("textbox" & K) = f.Cells(ligneEnreg, K)
Next K
For K = 6 To 11
Me("textbox" & K) = f.Cells(ligneEnreg, K)
Next K
End If
Next I
End Sub
Function SansDoublons(a())
Set d = CreateObject("Scripting.Dictionary")
For Each c In a
d(c) = ""
Next c
b = d.keys
SansDoublons = b
End Function
Sub raz()
For K = 1 To 3
Me("textbox" & K) = ""
Next K
For K = 6 To 11
Me("textbox" & K) = ""
Next K
End Sub |
Partager