Bonjour,
J'ai un classeur (A) dans lequel j'ai une macro sur un bouton clic(b) qui lance un USF.
Dans cet USF, des textbox dans lesquels il faut inscrire des données et un bouton clic(c) avec une macro qui enregistre ces données dans une ligne de tableau.
J'aimerais à partir d'un autre classeur(b), a l'aide d'une macro sur un bouton clic
- ouvrir classeur (A)
- lancer la macro du bouton clic (b) sans devoir cliquer sur le bouton
- fermer le classeur(A) après la macro du bouton clic (c)
- revenir au classeur (B)
J'ouvre le classeur (A) mais je n'arrive pas à trouver le code pour lancer la macro sur le bouton clic(b)
Pourriez-vous m'aiguiller?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Workbooks.Open Filename:= _ "E:\Liste_chantier.xlsm" 'Executer macro : Sub Nouveau_chantier() UserFormNouveau_chantier.Show End Sub 'Valider USF Private Sub Valider_chantier_Click() N_chantier = TextBox1.Value Nom_chantier = TextBox2.Value TAR = TextBox3.Value Rue = TextBox4.Value Rue_livraison = TextBox5.Value CP = TextBox6.Value Ville = TextBox7.Value Sheets("Liste").Select Dl = Cells(Rows.Count, 1).End(xlUp).Row + 1 Cells(Dl, 1) = N_chantier Cells(Dl, 2) = Nom_chantier Cells(Dl, 3) = Rue Cells(Dl, 4) = Rue_livraison Cells(Dl, 5) = CP Cells(Dl, 6) = Ville Cells(Dl, 7) = TAR ActiveWorkbook.Worksheets("Liste").ListObjects("Tableau1").Sort.SortFields. _ Clear ActiveWorkbook.Worksheets("Liste").ListObjects("Tableau1").Sort.SortFields.Add _ Key:=Range("Tableau1[[#All],[N° Chantier]]"), SortOn:=xlSortOnValues, _ Order:=xlAscending, DataOption:=xlSortNormal With ActiveWorkbook.Worksheets("Liste").ListObjects("Tableau1").Sort .Header = xlYes .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply End With TextBox1 = "" TextBox2 = "" TextBox3 = "" TextBox4 = "" TextBox5 = "" TextBox6 = "" TextBox7 = "" Sheets("Acceuil").Select UserFormNouveau_chantier.Hide Workbooks("Liste_chantier.xlsm").Save End Sub 'Fermer classeur Workbooks("Liste_chantier.xlsm").Close
Je vous remercie d'avance
Partager