Précédent   Forum des professionnels en informatique > Logiciels > Microsoft Office > Excel > Macros et VBA Excel
Macros et VBA Excel Vos questions relatives aux macros Excel, à l'utilisation de VBA et à l'automatisation de vos classeurs Excel.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 23/08/2011, 17h41   #1
Invité(e)
Invité(e)
 
Messages : n/a
Détails du profil
Informations forums :
Messages : n/a
Points : 0
Par défaut changer des checkbox par une liste déroulante

Bonjour !

voila j'ai un formulaire userform avec des checkbox et je veux mettre a la place des checkbox une liste déroulante sans change le code vba


code vba
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
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
 
 
Private Sub CommandButton1_Click()
 
 Dim LastRow As Single
 With ThisWorkbook.Sheets("AliOuat KhaOla")
  LastRow = .Range("C" & Rows.Count).End(xlUp).Row
 
  ' Mise à jour des cellules
  .Range("c" & LastRow + 1) = IIf(CheckBox1, TextBox1, "")
  .Range("d" & LastRow + 1) = IIf(CheckBox1, TextBox2, "")
  End With
 With ThisWorkbook.Sheets("Chtaibi Lamiae")
  LastRow = .Range("C" & Rows.Count).End(xlUp).Row
 
  ' Mise à jour des cellules
  .Range("c" & LastRow + 1) = IIf(CheckBox2, TextBox1, "")
  .Range("d" & LastRow + 1) = IIf(CheckBox2, TextBox2, "")
 End With
  With ThisWorkbook.Sheets("Amir Marouane")
  LastRow = .Range("C" & Rows.Count).End(xlUp).Row
 
  ' Mise à jour des cellules
  .Range("c" & LastRow + 1) = IIf(CheckBox11, TextBox1, "")
  .Range("d" & LastRow + 1) = IIf(CheckBox11, TextBox2, "")
 End With
 With ThisWorkbook.Sheets("Bourasse Ghizlane ")
  LastRow = .Range("C" & Rows.Count).End(xlUp).Row
 
  ' Mise à jour des cellules
  .Range("c" & LastRow + 1) = IIf(CheckBox10, TextBox1, "")
  .Range("d" & LastRow + 1) = IIf(CheckBox10, TextBox2, "")
 End With
  With ThisWorkbook.Sheets("Bounira Nabil ")
  LastRow = .Range("C" & Rows.Count).End(xlUp).Row
 
  ' Mise à jour des cellules
  .Range("c" & LastRow + 1) = IIf(CheckBox9, TextBox1, "")
  .Range("d" & LastRow + 1) = IIf(CheckBox9, TextBox2, "")
 End With
  With ThisWorkbook.Sheets("Amir Adnane")
  LastRow = .Range("C" & Rows.Count).End(xlUp).Row
 
  ' Mise à jour des cellules
  .Range("c" & LastRow + 1) = IIf(CheckBox8, TextBox1, "")
  .Range("d" & LastRow + 1) = IIf(CheckBox8, TextBox2, "")
 End With
  With ThisWorkbook.Sheets("Raji Rachid")
  LastRow = .Range("C" & Rows.Count).End(xlUp).Row
 
  ' Mise à jour des cellules
  .Range("c" & LastRow + 1) = IIf(CheckBox7, TextBox1, "")
  .Range("d" & LastRow + 1) = IIf(CheckBox7, TextBox2, "")
 End With
  With ThisWorkbook.Sheets("Ayane Sami")
  LastRow = .Range("C" & Rows.Count).End(xlUp).Row
 
  ' Mise à jour des cellules
  .Range("c" & LastRow + 1) = IIf(CheckBox3, TextBox1, "")
  .Range("d" & LastRow + 1) = IIf(CheckBox3, TextBox2, "")
 End With
  With ThisWorkbook.Sheets("Saboui Ismail")
  LastRow = .Range("C" & Rows.Count).End(xlUp).Row
 
  ' Mise à jour des cellules
  .Range("c" & LastRow + 1) = IIf(CheckBox5, TextBox1, "")
  .Range("d" & LastRow + 1) = IIf(CheckBox5, TextBox2, "")
 End With
  With ThisWorkbook.Sheets("Koudri Morad")
  LastRow = .Range("C" & Rows.Count).End(xlUp).Row
 
  ' Mise à jour des cellules
  .Range("c" & LastRow + 1) = IIf(CheckBox6, TextBox1, "")
  .Range("d" & LastRow + 1) = IIf(CheckBox6, TextBox2, "")
 End With
  With ThisWorkbook.Sheets("Bachiri Reda")
  LastRow = .Range("C" & Rows.Count).End(xlUp).Row
 
  ' Mise à jour des cellules
  .Range("c" & LastRow + 1) = IIf(CheckBox4, TextBox1, "")
  .Range("d" & LastRow + 1) = IIf(CheckBox4, TextBox2, "")
 End With
   With ThisWorkbook.Sheets("Mes PrOjets")
  LastRow = .Range("C" & Rows.Count).End(xlUp).Row
 
  ' Mise à jour des cellules
  .Range("c" & LastRow + 1) = TextBox1
  .Range("d" & LastRow + 1) = TextBox2
 End With
 Unload Me ' Fermer la UserForm
 ActiveWorkbook.Save
 ActiveWorkbook.Close
 
 End Sub
 
Private Sub CommandButton2_Click()
Unload Me ' Fermer la UserForm
Application.Visible = True
End Sub
  Envoyer un message privé Réponse avec citation 02
Vieux 23/08/2011, 17h57   #2
Rédacteur/Modérateur
 
Avatar de Philippe JOCHMANS
 
Homme Philippe JOCHMANS
Développeur informatique
Inscription : mai 2005
Messages : 17 620
Détails du profil
Informations personnelles :
Nom : Homme Philippe JOCHMANS
Âge : 44
Localisation : France, Loir et Cher (Centre)

Informations professionnelles :
Activité : Développeur informatique
Secteur : Communication - Médias

Informations forums :
Inscription : mai 2005
Messages : 17 620
Points : 30 954
Points : 30 954
Envoyer un message via MSN à Philippe JOCHMANS Envoyer un message via Skype™ à Philippe JOCHMANS
Bonjour

Il faudrait que tu détailles le pourquoi de ce changement voulu.

Les Chekbox et les zones de listes n'ont pas les mêmes méthodes et propriétés, de plus leur comportement est différent et sans changer le code c'est impossible.

Philippe
__________________
Détaillez vos questions, sinon vous aurez des réponses erronées et vous irez tout droit dans le et lisez les règles sinon
Si vous pensez commencer sans un livre, oublier : livres pour débuter
Vous pouvez consulter mes articles sur Access et PowerPoint
Le blog Office.

Inutile de m'envoyer un MP pour des questions techniques ou de me relancer , je n'y répondrais pas.
Philippe JOCHMANS est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 23/08/2011, 23h57   #3
Invité(e)
Invité(e)
 
Messages : n/a
Détails du profil
Informations forums :
Messages : n/a
Points : 0
dessole j'ai mal formulé
je veux dire par sans changer le code
sans changer la fonctionnalité du code

voila le classeur j'ai créer dans le UserForm 2 page la premier contiens les checkbox et la deuxième la liste déroulante maintenant je veux faire un code pour exécute la deuxième page mais qui a la même fonction de la premier
Fichiers attachés
Type de fichier : xls Nouveau Projet.xls (90,5 Ko, 7 affichages)

Dernière modification par AlainTech ; 25/08/2011 à 07h56. Motif: Fusion de 2 messages
  Envoyer un message privé Réponse avec citation 01
Vieux 24/08/2011, 11h53   #4
Invité(e)
Invité(e)
 
Messages : n/a
Détails du profil
Informations forums :
Messages : n/a
Points : 0
Problème résolu j'ai réussi a le débloquer moi même
Voici les code

Code pour les checkbox
Code :
1
2
3
4
5
6
7
8
9
 
 Dim LastRow As Single
 With ThisWorkbook.Sheets("AliOuat KhaOla")
  LastRow = .Range("C" & Rows.Count).End(xlUp).Row
 
  ' Mise à jour des cellules
  .Range("c" & LastRow + 1) = IIf(CheckBox1, TextBox1, "")
  .Range("d" & LastRow + 1) = IIf(CheckBox1, TextBox2, "")
  End With
et le code pour la liste déroulante
Code :
1
2
3
4
5
6
7
8
9
 
 Dim LastRow As Single
 With ThisWorkbook.Sheets("AliOuat KhaOla")
  LastRow = .Range("C" & Rows.Count).End(xlUp).Row
 
  ' Mise à jour des cellules
  .Range("c" & LastRow + 1) = IIf(ComboBox1.ListIndex = 0, TextBox1, "")
  .Range("d" & LastRow + 1) = IIf(ComboBox1.ListIndex = 0, TextBox1, "")
  End With

Dernière modification par Invité(e) ; 24/08/2011 à 15h30.
  Envoyer un message privé Réponse avec citation 01
Réponse Proposer ce sujet en actualité Enlever Résolu
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 16h46.


 
 
 
 
Partenaires

Hébergement Web