condition dans une boucle
Bonjour à tous,
Dans une boucle de type for i=, je voudrais inclure une autre condition en if
La boucle vient mettre des information sur les colonne de A jusqu'à I, issue d'une saisie sur un formulaire
mon soucis est la colonne F ou je veux mettre inclure 3 informations
les deux premières sont issue de l'addition de deux textbox ("txt_pv" et "txt_sacem") du formulaire
la troisième dépend d'une information texte situé dans une combobox ("cmb_nom") selon le résultat, je voudrais ajouter 22 au résultat des 2 première textbox
actuellement le code est celui-ci
Code:
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
|
Dim cmb_nom01 As String
Dim cmb_nom02 As String
Dim cmb_nom03 As String
Dim cmb_nom04 As String
Dim cmb_nom05 As String
Dim cmb_nom06 As String
Dim cmb_nom07 As String
Dim cmb_nom08 As String
Dim cmb_nom09 As String
Dim cmb_nom10 As String
Dim cmb_nom11 As String
Dim cmb_nom12 As String
Dim cmb_nom13 As String
Dim cmb_nom14 As String
On Error Resume Next
'inscrire les noms en feuille n°de commande
If Me.cmb_nom01.Value <> "" Then Sheets("n°commande").Range("e65536").End(xlUp).Offset(1, 0) = Me.cmb_nom01
If Me.cmb_nom02.Value <> "" Then Sheets("n°commande").Range("e65536").End(xlUp).Offset(1, 0) = Me.cmb_nom02
If Me.cmb_nom03.Value <> "" Then Sheets("n°commande").Range("e65536").End(xlUp).Offset(1, 0) = Me.cmb_nom03
If Me.cmb_nom04.Value <> "" Then Sheets("n°commande").Range("e65536").End(xlUp).Offset(1, 0) = Me.cmb_nom04
If Me.cmb_nom05.Value <> "" Then Sheets("n°commande").Range("e65536").End(xlUp).Offset(1, 0) = Me.cmb_nom05
If Me.cmb_nom06.Value <> "" Then Sheets("n°commande").Range("e65536").End(xlUp).Offset(1, 0) = Me.cmb_nom06
If Me.cmb_nom07.Value <> "" Then Sheets("n°commande").Range("e65536").End(xlUp).Offset(1, 0) = Me.cmb_nom07
If Me.cmb_nom08.Value <> "" Then Sheets("n°commande").Range("e65536").End(xlUp).Offset(1, 0) = Me.cmb_nom08
If Me.cmb_nom09.Value <> "" Then Sheets("n°commande").Range("e65536").End(xlUp).Offset(1, 0) = Me.cmb_nom09
If Me.cmb_nom10.Value <> "" Then Sheets("n°commande").Range("e65536").End(xlUp).Offset(1, 0) = Me.cmb_nom10
If Me.cmb_nom11.Value <> "" Then Sheets("n°commande").Range("e65536").End(xlUp).Offset(1, 0) = Me.cmb_nom11
If Me.cmb_nom12.Value <> "" Then Sheets("n°commande").Range("e65536").End(xlUp).Offset(1, 0) = Me.cmb_nom12
If Me.cmb_nom13.Value <> "" Then Sheets("n°commande").Range("e65536").End(xlUp).Offset(1, 0) = Me.cmb_nom13
If Me.cmb_nom14.Value <> "" Then Sheets("n°commande").Range("e65536").End(xlUp).Offset(1, 0) = Me.cmb_nom14
Sheets("commandeelectro").Select
Dim i As Byte, Indice As Byte, derlig As Integer
With Worksheets("commandeelectro")
derlig = .Range("A" & .Rows.Count).End(xlUp).Row
For i = 1 To 14
If Controls("cmb_nom" & Format(i, "00")) <> "" Then
Indice = Indice + 1
.Range("A" & Indice + derlig) = Controls("commande" & Format(i, "00"))
.Range("b" & Indice + derlig) = Controls("cmb_nom" & Format(i, "00"))
.Range("c" & Indice + derlig) = Controls("cmb_type" & Format(i, "00"))
.Range("d" & Indice + derlig) = Controls("cmb_marque" & Format(i, "00"))
.Range("e" & Indice + derlig) = Controls("txt_ref" & Format(i, "00"))
End If |
j'ai essayé ceci
Code:
1 2
|
.if range("c" & Indice + derlig).Value ="Leger Garantie" then Range("q" & Indice + derlig)= controls("txt_pv" & Format(i, "00")) + Controls("txt_sacem" & Format(i, "00"))+22 |
Mais j'obtiens le message attendu : fin d'instruction
Merci pour votre aide