Ajout a des colonnes sous une condition
wakafa
Messages postés
39
Date d'inscription
Statut
Membre
Dernière intervention
-
f894009 Messages postés 17277 Date d'inscription Statut Membre Dernière intervention -
f894009 Messages postés 17277 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
je veux insérer des données via une interface VBA ,sous des conditions si OptionButton1= true and OptionButton3 il doit me faire l'ajout dans les colonnes B,C et D et ainsi de suite...
voila le code que j'ai utilisé mais malheureusement ça marche pas
Private Sub CommandButton1_Click()
Dim U As Integer
U = Sheets("Feuil5").Range("B" & Rows.Count).End(xlUp).Row + 1
If MsgBox("Etes vous sûr de vouloir ajouter ces informations?", vbYesNo, "Demande de confirmation") = vbYes Then
If OptionButton1 = True & OptionButton3 = True Then
Feuil5.Range("B" & U) = Val(TextBox1)
Feuil5.Range("C" & U).Value = ComboBox3
Feuil5.Range("D" & U).Value = ComboBox4
End If
If OptionButton1 = True & OptionButton4 = True Then
Feuil5.Range("E" & U) = Val(TextBox1)
Feuil5.Range("F" & U).Value = ComboBox3
Feuil5.Range("G" & U).Value = ComboBox4
End If
If OptionButton1 = True & OptionButton5 = True Then
Feuil5.Range("H" & U) = Val(TextBox1)
Feuil5.Range("I" & U).Value = ComboBox3
Feuil5.Range("J" & U).Value = ComboBox4
End If
If OptionButton2 = True & OptionButton3 = True Then
Feuil5.Range("L" & U) = Val(TextBox1)
Feuil5.Range("M" & U).Value = ComboBox3
Feuil5.Range("N" & U).Value = ComboBox4
End If
If OptionButton2 = True & OptionButton4 = True Then
Feuil5.Range("O" & U) = Val(TextBox1)
Feuil5.Range("P" & U).Value = ComboBox3
Feuil5.Range("Q" & U).Value = ComboBox4
End If
If OptionButton2 = True & OptionButton5 = True Then
Feuil5.Range("R" & U) = Val(TextBox1)
Feuil5.Range("S" & U).Value = ComboBox3
Feuil5.Range("T" & U).Value = ComboBox4
End If
End If
End Sub
je veux insérer des données via une interface VBA ,sous des conditions si OptionButton1= true and OptionButton3 il doit me faire l'ajout dans les colonnes B,C et D et ainsi de suite...
voila le code que j'ai utilisé mais malheureusement ça marche pas
Private Sub CommandButton1_Click()
Dim U As Integer
U = Sheets("Feuil5").Range("B" & Rows.Count).End(xlUp).Row + 1
If MsgBox("Etes vous sûr de vouloir ajouter ces informations?", vbYesNo, "Demande de confirmation") = vbYes Then
If OptionButton1 = True & OptionButton3 = True Then
Feuil5.Range("B" & U) = Val(TextBox1)
Feuil5.Range("C" & U).Value = ComboBox3
Feuil5.Range("D" & U).Value = ComboBox4
End If
If OptionButton1 = True & OptionButton4 = True Then
Feuil5.Range("E" & U) = Val(TextBox1)
Feuil5.Range("F" & U).Value = ComboBox3
Feuil5.Range("G" & U).Value = ComboBox4
End If
If OptionButton1 = True & OptionButton5 = True Then
Feuil5.Range("H" & U) = Val(TextBox1)
Feuil5.Range("I" & U).Value = ComboBox3
Feuil5.Range("J" & U).Value = ComboBox4
End If
If OptionButton2 = True & OptionButton3 = True Then
Feuil5.Range("L" & U) = Val(TextBox1)
Feuil5.Range("M" & U).Value = ComboBox3
Feuil5.Range("N" & U).Value = ComboBox4
End If
If OptionButton2 = True & OptionButton4 = True Then
Feuil5.Range("O" & U) = Val(TextBox1)
Feuil5.Range("P" & U).Value = ComboBox3
Feuil5.Range("Q" & U).Value = ComboBox4
End If
If OptionButton2 = True & OptionButton5 = True Then
Feuil5.Range("R" & U) = Val(TextBox1)
Feuil5.Range("S" & U).Value = ComboBox3
Feuil5.Range("T" & U).Value = ComboBox4
End If
End If
End Sub
A voir également:
- Ajout a des colonnes sous une condition
- Comment faire des colonnes sur word - Guide
- Formule moyenne excel plusieurs colonnes - Guide
- Excel cellule couleur si condition texte - Guide
- Déplacer une colonne excel - Guide
- Classer par ordre alphabétique excel plusieurs colonnes - Guide
1 réponse
Bonjour,
comme ca ira mieux:
Pour Infos: si vous voulez faire un ET pour x test:
comme ca ira mieux:
Private Sub CommandButton1_Click() Dim U As Integer U = Sheets("Feuil5").Range("B" & Rows.Count).End(xlUp).Row + 1 If MsgBox("Etes vous sûr de vouloir ajouter ces informations?", vbYesNo, "Demande de confirmation") = vbYes Then If OptionButton1 = True Then If OptionButton3 = True Then Feuil5.Range("B" & U) = Val(TextBox1) Feuil5.Range("C" & U).Value = ComboBox3 Feuil5.Range("D" & U).Value = ComboBox4 ElseIf OptionButton4 = True Then Feuil5.Range("E" & U) = Val(TextBox1) Feuil5.Range("F" & U).Value = ComboBox3 Feuil5.Range("G" & U).Value = ComboBox4 ElseIf OptionButton5 = True Then Feuil5.Range("H" & U) = Val(TextBox1) Feuil5.Range("I" & U).Value = ComboBox3 Feuil5.Range("J" & U).Value = ComboBox4 End If End If If OptionButton2 = True Then If OptionButton3 = True Then Feuil5.Range("L" & U) = Val(TextBox1) Feuil5.Range("M" & U).Value = ComboBox3 Feuil5.Range("N" & U).Value = ComboBox4 ElseIf OptionButton4 = True Then Feuil5.Range("O" & U) = Val(TextBox1) Feuil5.Range("P" & U).Value = ComboBox3 Feuil5.Range("Q" & U).Value = ComboBox4 ElseIf OptionButton5 = True Then Feuil5.Range("R" & U) = Val(TextBox1) Feuil5.Range("S" & U).Value = ComboBox3 Feuil5.Range("T" & U).Value = ComboBox4 End If End If End If End Sub
Pour Infos: si vous voulez faire un ET pour x test:
If OptionButton1 = True And OptionButton3 = True Then