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 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
| Private Sub CommandButton1_Click()
Sheets("test").Activate
Range("f11").Activate
ActiveCell = ComboBox1.Value
Range("j11").Activate
ActiveCell = ComboBox2.Value
Range("b25").Activate
ActiveCell = TextBox1.Value
' valeur des motifs
Range("f19").Activate
ActiveCell = ComboBox3.Value
Range("i19").Activate
ActiveCell = ComboBox4.Value
Range("l19").Activate
ActiveCell = ComboBox5.Value
période.Hide
' test # nature
Dim nat1, nat2, nat3
nat1 = Cells(27, 8).Value
nat2 = Cells(27, 11).Value
nat3 = Cells(27, 14).Value
If nat1 = 1 And nat2 = 1 Then MsgBox "Erreur: nombre demi-journées"
If nat1 = 1 And nat3 = 1 Then MsgBox "Erreur: nombre demi-journées"
If nat1 = 1 And nat2 = 1 Then période.Show
If nat1 = 1 And nat3 = 1 Then période.Show
If nat1 = 0 And nat2 = 0 And nat3 = 0 Then MsgBox "Erreur: vous devez introduire la nature du congé"
If nat1 = 0 And nat2 = 0 And nat3 = 0 Then période.Show
' envoi des données dans BD_Congés
Dim dat101, dat102, nature1, nature2, nature3, natureX, agentX, comm
agentX = Cells(2, 1).Value
dat101 = Cells(17, 1).Value
dat102 = Cells(17, 2).Value
nature1 = Cells(19, 6).Value
nature2 = Cells(19, 9).Value
nature3 = Cells(19, 12).Value
comm = Cells(25, 2).Value
If nature1 <> "" Then natureX = nature1
If nature1 = "" Then natureX = nature2 + "/" + nature3
If agentX = "00061141" Or agentX = "00000332" Or agentX = "00061404" And nature1 <> "" Then natureX = natureX + "!"
' If agentX = "00061141" Or agentX = "00000332" Or agentX = "00061404" And nature1 = "" Then natureX = nature2 + "/" + nature3 + "!"
' permet d'ouvrir le fichier en lecture seule avec boucle si occupé
Line2:
Workbooks.Open Filename:= _
"I:\Bruxelles-Brussel\PFG\Pierre V - 610\CALENDRIER DES CONGES DR\Classeur des congés761.xls"
If ActiveWorkbook.ReadOnly Then ouv = 1 Else ouv = 0
If ActiveWorkbook.ReadOnly Then ActiveWorkbook.Close 'Application.Quit
If ouv = 1 Then GoTo Line2
' fin boucle si occupé
ActiveSheet.Unprotect Password:="onafts"
For i = dat101 To dat102
Columns("A:A").Select
Range("a1").Activate
Dim cellagent
If agentX = "00000332" Then cellagent = 2
If agentX = "00061404" Then cellagent = 3
If agentX = "00000831" Then cellagent = 4
If agentX = "00000262" Then cellagent = 5
If agentX = "00060046" Then cellagent = 6
If agentX = "00000395" Then cellagent = 7
If agentX = "00000386" Then cellagent = 8
If agentX = "00060106" Then cellagent = 9
If agentX = "00060787" Then cellagent = 10
If agentX = "00061227" Then cellagent = 11
If agentX = "00061427" Then cellagent = 12
If agentX = "00062130" Then cellagent = 13
If agentX = "00000397" Then cellagent = 14
If agentX = "00000854" Then cellagent = 15
If agentX = "00062171" Then cellagent = 16
If agentX = "00062083" Then cellagent = 17
If agentX = "00062114" Then cellagent = 18
If agentX = "00061595" Then cellagent = 19
If agentX = "00061581" Then cellagent = 20
If agentX = "00102361" Then cellagent = 21
If agentX = "00000388" Then cellagent = 22
If agentX = "00061697" Then cellagent = 23
If agentX = "00061949" Then cellagent = 24
If agentX = "00000385" Then cellagent = 25
If agentX = "00062095" Then cellagent = 26
If agentX = "00000975" Then cellagent = 27
If agentX = "00062068" Then cellagent = 28
If agentX = "00062084" Then cellagent = 29
If agentX = "00061978" Then cellagent = 30
If agentX = "00000357" Then cellagent = 31
If agentX = "00062085" Then cellagent = 32
If agentX = "00062137" Then cellagent = 33
If agentX = "00000392" Then cellagent = 34
If agentX = "00000699" Then cellagent = 35
If agentX = "00061951" Then cellagent = 36
If agentX = "00000381" Then cellagent = 37
If agentX = "00000394" Then cellagent = 38
If agentX = "00061580" Then cellagent = 39
If agentX = "00000608" Then cellagent = 40
If agentX = "00061855" Then cellagent = 41
If agentX = "00061979" Then cellagent = 42
If agentX = "00060739" Then cellagent = 43
Selection.Find(What:=i, After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(rowoffset:=0, columnoffset:=cellagent).Activate
If ActiveCell <> "" Then GoTo line3
ActiveCell = natureX
If comm = "" Then GoTo line3
ActiveCell.AddComment comm
ActiveCell.comment.Visible = False
line3:
Next i
ActiveSheet.Protect Password:="onafts", DrawingObjects:=True, contents:=True, Scenarios:=True
ActiveWorkbook.Save
ActiveWindow.Close
line123:
Dmd_congés_Vérif.Show
End Sub |
Partager