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
|
Private Sub CommandButton1_Click()
ChDir "C:\testmathieu"
Workbooks.Open Filename:="C:\testmathieu\test.xls"
If ComboBox1.Text = "CCAS.XLS" Then
Windows("CCAS").Activate
Sheets("Bulletins de paye").Select
Sheets("Bulletins de paye").Copy Before:=Workbooks("test.xls").Sheets(1)
If ComboBox2.Text = "CCAS_nat.XLS" Then
Workbooks.Open Filename:="C:\testmathieu\CCAS_nat.xls"
Windows("CCAS_nat").Activate
Sheets("Répartition par nature").Select
Sheets("Répartition par nature").Copy Before:=Workbooks("test.xls").Sheets(1)
If ComboBox3.Text = "ville.XLS" Then
Workbooks.Open Filename:="C:\testmathieu\ville.xls"
Windows("ville").Activate
Sheets("Bulletins de paye").Select
Sheets("Bulletins de paye").Copy Before:=Workbooks("test.xls").Sheets(1)
If ComboBox4.Text = "ville_nat.XLS" Then
Workbooks.Open Filename:="C:\testmathieu\ville_nat.xls"
Windows("ville_nat").Activate
Sheets("Répartition par nature").Select
Sheets("Répartition par nature").Copy Before:=Workbooks("test.xls").Sheets(1)
Application.DisplayAlerts = False
Workbooks("test.xls").Sheets("Feuil1").Delete
Workbooks("test.xls").Sheets("Feuil2").Delete
Workbooks("test.xls").Sheets("Feuil3").Delete
Application.DisplayAlerts = True
End If
End If
End If
End If
Windows("CCAS.xls").Visible = False
Windows("CCAS_nat.xls").Visible = False
Windows("ville.xls").Visible = False
Windows("ville_nat.xls").Visible = False
End Sub
Private Sub UserForm_Activate()
Dim I As Integer, Chemin As String, Fichier As String
Chemin = "C:\testmathieu\*.xls"
Fichier = Dir(Chemin)
Do While (Len(Fichier) > 0)
Me.ComboBox1.AddItem Fichier
Me.ComboBox2.AddItem Fichier
Me.ComboBox3.AddItem Fichier
Me.ComboBox4.AddItem Fichier
Fichier = Dir()
Loop
End Sub |