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
| Private Sub ComboBox2_Change()
ligne1 = [B6].Offset(ComboBox2.ListIndex, 0).Row
Me.TextBox1.Text = Cells(ligne1, 7)
Me.TextBox2.Text = Cells(ligne1, 8)
Me.ComboBox1.Text = Cells(ligne1, 1)
Me.ComboBox2.Text = Cells(ligne1, 2)
Me.ComboBox3.Text = Cells(ligne1, 3)
Me.ComboBox4.Text = Cells(ligne1, 4)
Me.ComboBox5.Text = Cells(ligne1, 5)
Me.ComboBox6.Text = Cells(ligne1, 6)
If Dir(ThisWorkbook.Path & "\Photos" & "\" & ComboBox2 & ".jpg") = "" Then
Me.Image1.Picture = LoadPicture("")
Else
Me.Image1.Picture = LoadPicture(ThisWorkbook.Path & "\photos" & "\" & ComboBox2 & ".jpg")
End If
Label11.Caption = ComboBox2.ListIndex + 1
Label15.Caption = ComboBox2.ListCount
Range("A6").Offset(ComboBox1.ListIndex, 0).Select
Application.ScreenUpdating = False
End Sub
Private Sub CommandButton1_Click()
'... la premiere ligne du tableau les 3 lignes retournent le même résultat
'var = Sheets("base").Range("A:A").End(xlDown).Row + 1
ligne = Cells(Rows.Count, 1).End(xlUp).Row + 1
'linsuiv = Sheets("base").Range("A1048576").End(xlUp).Row + 1
r = MsgBox("Voulez-vous confirmer la modification?", vbYesNo, "Modification Objet")
If r <> 6 Then Exit Sub
For i = 1 To linsuiv
linsuiv.Active
While ComboBox2.Text = Cells(i, 2)
Rows(i).Select
Cells(i, 1) = ComboBox1.Text
Cells(i, 3) = ComboBox3.Text
Cells(i, 4) = ComboBox4.Text
Cells(i, 5) = ComboBox5.Text
Cells(i, 6) = ComboBox6.Text
Cells(i, 7) = TextBox1.Text
Cells(i, 8) = TextBox2.Text
i = i + 1
Wend
Next i
End Sub
Private Sub CommandButton2_Click()
If ComboBox2.Text = "" Then MsgBox ("aucun enregistrement à supprimer"): Exit Sub
r = MsgBox("voulez-vous confirmer la suppression de cet objet?", vbYesNo, "Suppression objet")
If r <> 6 Then Exit Sub
Selection.EntireRow.Delete
End Sub
Private Sub CommandButton3_Click()
image_path = Application.GetOpenFilename(filefilter:="picture files(fichiers image),*.gif;*.jpg;*.jpeg;*.bmp", Title:="choisir image")
If image_path <> False Then
Me.Image1.Picture = LoadPicture(image_path)
Me.Image1.Visible = True
End If
var = ComboBox2.Text
SavePicture Image1.Picture, ThisWorkbook.Path & "\photos\" & var & ".jpg" ' enregistrer l'image choisie dans le dossier photos avec l'extension jpg
Application.ScreenUpdating = False
End Sub
Private Sub CommandButton4_Click()
ComboBox2.ListIndex = ComboBox2.ListCount - 1
Application.ScreenUpdating = False
End Sub
Private Sub CommandButton5_Click()
If Me.ComboBox2.ListIndex > 0 Then
Me.ComboBox2.ListIndex = Me.ComboBox2.ListIndex - 1
End If
Application.ScreenUpdating = False
End Sub
Private Sub CommandButton6_Click()
If Me.ComboBox2.ListIndex < Me.ComboBox2.ListCount - 1 Then
Me.ComboBox2.ListIndex = Me.ComboBox2.ListIndex + 1
End If
Application.ScreenUpdating = False
End Sub
Private Sub CommandButton7_Click()
ComboBox2.ListIndex = 0
Application.ScreenUpdating = False
End Sub
Private Sub UserForm_Initialize()
Sheets("Base").Activate
ligne = Range("A" & Rows.Count).End(xlUp).Row
ComboBox1.RowSource = "A6:A" & ligne
ligne = Range("B" & Rows.Count).End(xlUp).Row
ComboBox2.RowSource = "B6:B" & ligne
ComboBox3.AddItem ""
ComboBox3.AddItem "AAA"
ComboBox3.AddItem "BBB"
ComboBox3.AddItem "CCC"
ComboBox4.AddItem ""
ComboBox4.AddItem "EEE"
ComboBox4.AddItem "FFF"
ComboBox4.AddItem "GGG "
ComboBox5.AddItem ""
ComboBox5.AddItem "Oui"
ComboBox5.AddItem "Non"
ComboBox6.AddItem ""
ComboBox6.AddItem "Oui"
ComboBox6.AddItem "Non"
End Sub |
Partager