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 127 128
| Private Sub CommandButton1_Click()
'Bouton "Ajout"
'Ajout des éléments Choix dans case Détail poste ListBox1
ListBox1.AddItem TextBox_choix.Value
'Ajout qté dans 2ème case Détail poste ListBox2
ListBox2.AddItem TextBox_Qte.Value
'Remise à 0 des cases supérieures
TextBox_Qte.Value = ""
TextBox_choix.Value = ""
ListBox_dep.Clear
ComboBox_htdep.Clear
ComboBox3.Clear
ComboBox_inf_Change
ComboBox_acc_Change
End Sub
Private Sub CommandButton2_Click() 'Bouton "Validation poste"
Dim copie1 As String
Dim copie2 As String
Dim derlign As Double
Dim i As Long
Dim test As Variant
Sheets("travail").Select 'sélection feuille Travail
For i = 1 To ListBox1.ListCount 'liste les produits dans Détail Poste (ListBox1)
copie1 = ListBox1.List(i - 1) 'copie de la liste Détail Poste
Range("L" & i) = copie1 '
copie2 = ListBox2.List(i - 1) 'liste les Qté dans Détail Poste (ListBox2)
Range("Q" & i) = copie2
test = Range("Q" & i).Value 'Test = Valeur colonne Q et liste Détail Poste
If Not test = "" Then
Range("N" & i).Formula = "=VLOOKUP(L" & i & ",'base de donnée'!$B$1:$L$8000,10,FALSE)" 'P.U
Range("O" & i).Formula = "=VLOOKUP(L" & i & ",'base de donnée'!$B$1:$L$8000,6,FALSE)*Q" & i 'DEEE
Range("P" & i).Formula = "=VLOOKUP(L" & i & ",'base de donnée'!$B$1:$L$8000,7,FALSE)" 'DEA
Range("R" & i).Formula = "=Q" & i & "*N" & i 'Prix TOTAL
'Ancien code
'Range("N" & i).Select 'Colonne Poids
'ActiveCell.FormulaR1C1 = _
' "=VLOOKUP(RC[-2],'base de donnée'!R2C1:R911C9,10,FALSE)"
'Range("O" & i).Select 'Colonne DEEE
'ActiveCell.FormulaR1C1 = _
' "=VLOOKUP(RC[-3],'base de donnée'!R2C2:R911C9,3,FALSE)"
'Range("P" & i).Select 'Colonne DEA
'ActiveCell.FormulaR1C1 = _
' "=VLOOKUP(RC[-4],'base de donnée'!R2C1:R911C9,7,FALSE)*RC[1]"
'Range("R" & i).Select 'Colonne
'ActiveCell.FormulaR1C1 = "=RC[-1]*RC[-3]"
End If
Next i
i = i - 1
Range("L1 :R" & i).Copy 'Copie sélection coller provisoirement en colonne LMNOPQR
derlign = Range("A" & Rows.Count).End(xlUp).Row 'dernière ligne colonne A
derlign = derlign + 1 'dernière ligne +1
Cells(derlign, 1).Select 'Sélection dernière ligne
ActiveSheet.Paste 'Collage
Range("L:S").ClearContents 'Efface Colonne L à S
ListBox1.Clear 'Efface Détail Poste
ListBox2.Clear 'Efface Qté Détail Poste
TextBox2.Value = "" 'Efface Poste
End Sub
Private Sub CommandButton3_Click()
'Bouton "Annulation de poste"
Application.ScreenUpdating = False
ListBox1.AddItem TextBox_choix.Value 'Ajout dans Détail poste du Choix
ListBox2.AddItem TextBox_Qte.Value 'Ajout dans Qté détail poste de Qté
TextBox_Qte.Value = "" 'Remise à 0 case Qté
TextBox_choix.Value = "" 'Remise à 0 case Choix
ListBox_dep.Clear 'Remise à 0 ListBox
ComboBox_htdep.Clear 'Remise à 0 Hauteur
ComboBox3.Clear 'Remise à 0 Dimensions
ComboBox_inf_Change 'Remise à 0 Infra
ComboBox_acc_Change 'Remise à 0 Accessoires
Sheets("travail").Activate 'Activation onglet Travail
Range("L:L").ClearContents 'Efface colonne L
Range("R:R").ClearContents 'Efface colonne R
ListBox1.Clear 'Efface Détail Poste
ListBox2.Clear 'Efface Qté détail poste
TextBox2.Value = "" 'Efface Poste
End Sub
Private Sub CommandButton4_Click()
'Bouton Terminer
If Not TextBox2 = "" Then 'Si Poste vide -> message
MsgBox ("Veuillez valider votre poste")
Exit Sub
End If
Unload insertion 'ne pas charger
End Sub |
Partager