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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
| Private Declare Function GetWindowLongA Lib "user32" _
(ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLongA Lib "user32" _
(ByVal hwnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function FindWindowA Lib "user32" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Dim f, nbCol, pointeur, ligne
Private Sub UserForm_Initialize()
Set f = Sheets("Tool_BDES")
ligne = 2
nbCol = f.[A1].CurrentRegion.Columns.Count
x = 10
y = 10
For i = 1 To nbCol
retour = Me.Controls.Add("Forms.Label.1", "Label" & i, True)
Me("label" & i).Caption = f.Cells(1, i)
Me("label" & i).Top = y
Me("label" & i).Left = x
retour = Me.Controls.Add("Forms.TextBox.1", "TextBox" & i, True)
Me("textbox" & i).Top = y
Me("textbox" & i).Left = x + 150
Me("textbox" & i).Width = f.Columns(i).Width + 4
'Me("textbox" & i).Value = f.Cells(ligne, i)
y = y + 20
Next
retour = Me.Controls.Add("Forms.Label.1", "Label" & i, True)
Me("label" & i).Caption = f.Cells(1, 1)
Me("label" & i).Top = Me.ListDossier_2.Top - 10
Me("label" & i).Left = Me.ListDossier_2.Left + 2
'--
For i = 2 To f.[A65000].End(xlUp).Row
Me.ListDossier_2.AddItem
Me.ListDossier_2.List(i - 2, 0) = f.Cells(i, 1)
Me.ListDossier_2.List(i - 2, 1) = i
Next
If nbCol > 8 Then Me.Height = y + 30
pointeur = 0
ligne = Me.ListDossier_2.List(pointeur, 1)
affiche
Dim hwnd As Long
hwnd = FindWindowA("Thunder" & IIf(Application.Version Like "8*", _
"X", "D") & "Frame", Me.Caption)
SetWindowLongA hwnd, -16, GetWindowLongA(hwnd, -16) And &HFFF7FFFF
End Sub
Private Sub ListDossier_2_Click()
ligne = Me.ListDossier_2.Column(1)
pointeur = Me.ListDossier_2.ListIndex
affiche
End Sub
Private Sub BoutonSuiv2_Click()
If pointeur < Me.ListDossier_2.ListCount - 1 Then
pointeur = pointeur + 1
ligne = Me.ListDossier_2.List(pointeur, 1)
affiche
End If
End Sub
Private Sub BoutonPrec2_Click()
If pointeur > 0 Then
pointeur = pointeur - 1
ligne = Me.ListDossier_2.List(pointeur, 1)
affiche
End If
End Sub
Private Sub BoutonHautListe2_Click()
pointeur = 0
ligne = Me.ListDossier_2.List(pointeur, 1)
affiche
End Sub
Private Sub BoutonFinListe2_Click()
pointeur = Me.ListDossier_2.ListCount - 1
ligne = Me.ListDossier_2.List(pointeur, 1)
affiche
End Sub
Private Sub BoutonValider2_Click()
Me.ListDossier_2.Clear
i = 0
Set plage = f.[A1].CurrentRegion
Set c = plage.Find(Me.MotCle2, , , xlPart)
If Not c Is Nothing Then
premier = c.Address
Do
Me.ListDossier_2.AddItem
lig = c.Row
Me.ListDossier_2.List(i, 0) = plage.Cells(lig, 1)
Me.ListDossier_2.List(i, 1) = lig
i = i + 1
Set c = plage.FindNext(c)
Loop While Not c Is Nothing And c.Address <> premier
End If
pointeur = 0
ligne = Me.ListDossier_2.List(pointeur, 1)
affiche
End Sub
Private Sub BoutonToutSelc2_Click()
Me.ListDossier_2.Clear
For i = 2 To f.[A65536].End(xlUp).Row
Me.ListDossier_2.AddItem
Me.ListDossier_2.List(i - 2, 0) = f.Cells(i, 1)
Me.ListDossier_2.List(i - 2, 1) = i
Next
pointeur = 0
ligne = Me.ListDossier_2.List(pointeur, 1)
affiche
End Sub
Sub affiche()
For i = 1 To nbCol:
Me("textbox" & i).Value = f.Cells(ligne, i)
w = Evaluate("Cell(""format""," & f.Cells(ligne, i).Address & ")")
If Left(w, 1) = "C" Then Me("textbox" & i).Value = Format(f.Cells(ligne, i), "0000.00 ")
Next i
End Sub
Private Sub Sortie_Click()
Unload UserForm5
UserForm1.Show
End Sub |
Partager