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 131 132 133 134 135 136 137 138 139 140 141 142
| Dim nom As String
Dim NomfichierOuvert As String
Dim Moiscourant As String
Dim Moi As Integer
Dim NomFeuille As String
Dim LigneFeuille As Long
Moi = Application.InputBox("Mois de saisie en chiffre ?")
'Moi = Month(Range("H5").Value)
MsgBox Moi
If Moi = 1 Then
Moiscourant = "janvier"
ElseIf M = 2 Then
Moiscourant = "février"
ElseIf Moi = 3 Then
Moiscourant = "mars"
ElseIf Moi = 4 Then
Moiscourant = "avril"
ElseIf Moi = 5 Then
Moiscourant = "mai"
ElseIf Moi = 6 Then
Moiscourant = "juin"
ElseIf Moi = 7 Then
Moiscourant = "juillet"
ElseIf Moi = 8 Then
Moiscourant = "août"
ElseIf Moi = 9 Then
Moiscourant = "septembre"
ElseIf Moi = 10 Then
Moiscourant = "octobre"
ElseIf Moi = 11 Then
Moiscourant = "novembre"
Else
Moiscourant = "décembre"
End If
NomFeuille = Moiscourant & " " & Year(Date)
MsgBox NomFeuille
NomfichierOuvert = ThisWorkbook.Name
MsgBox NomfichierOuvert
' ******* tri sur le nom SP *******
' *** SLA ***
Dim Lg As Integer
Lg = 1
statSP:
Lg = Lg + 1
Cells(Lg, 1).Activate
nom = ActiveCell.Value 'Range("A1").Value
nom = UCase(nom)
MsgBox nom
correction:
' *** recherche personnel pour stat sur vehicule ***
Dim Nomfichier As String, chemin As String
Dim wbExcel As Workbook
Nomfichier = "Stat.xlsx" 'fichier a ouvrir pour incrémenter
chemin = "C:\Users\pc_warriors\Documents\MTY_RH\test\"
Set wbExcel = Workbooks.Open(chemin & Nomfichier)
Dim CompteurCol As Long
'Dim AjoutCol As Integer
'Dim Valeur As Integer
Dim Periode As String
Dim ColFct As Integer
'Dim Vehicule As Integer
Dim Fonction As String
Dim Engin As String
Dim Commentaires As String
Dim N As Integer
Workbooks("stat.xlsx").Activate
Sheets("test").Select
Range("C1").Select
CompteurCol = 2 ' Changer la valeur pour chaque macro
LigneFeuille = 2
Do
CompteurCol = CompteurCol + 1
If Cells(1, CompteurCol).Formula = "F" Then
MsgBox ("Le SP : " & nom & " n'existe pas")
Exit Do
End If
Loop While Cells(1, CompteurCol).Formula <> nom
MsgBox CompteurCol
Periode = Cells(LigneFeuille, CompteurCol - 1).Value
MsgBox Periode
Engin = Cells(LigneFeuille, CompteurCol - 3).Value
For N = 1 To 3
LigneFeuille = LigneFeuille + 2
Fonction = Cells(LigneFeuille - 2, CompteurCol - 2).Value
'*** extraction commentaire ***
If Cells(LigneFeuille - 2, CompteurCol).Comment.Text <> "" Then
x = Len(Cells(LigneFeuille - 2, CompteurCol).Comment.Text)
For i = x To 1 Step -1
If Mid(Cells(LigneFeuille - 2, CompteurCol).Comment.Text, i, 1) = ":" Then
Exit For
End If
Next i
Commentaires = Right(Cells(LigneFeuille - 2, CompteurCol).Comment.Text, x - i - 1)
Workbooks("test_saisie.xlsm").Activate
Sheets("test").Select
Cells(Lg, 1).Activate
ActiveCell.Offset(0, 4) = Commentaires
ActiveCell.Offset(0, 1) = Periode
ActiveCell.Offset(0, 3) = Fonction
ActiveCell.Offset(0, 2) = Engin
Else
Workbooks("stat.xlsx").Activate
Sheets("test").Select
End If
Next N
'*** fermeture fichier stats ***
Workbooks("stat.xlsx").Close SaveChanges:=False
Fin:
End Sub |
Partager