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
| Dim WD As Worksheet
Sub test()
Dim Ommal As New Collection
Dim cel As Range
Dim i As Integer
Application.ScreenUpdating = False
'****************************nettoyer feuille ("Heures employés")
Set WD = Sheets("Heures employés")
WD.Activate
Cells.Select
Selection.ClearContents
'********************************collecter la liste des employés des feuilles nommée CLIENT + qqchose
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
If ws.Name Like "CLIENT*" Then
ws.Activate
On Error Resume Next
For Each cell In ws.Range("D9:D" & [D65000].End(xlUp).Row)
If cell.Value <> "" Then
Ommal.Add cell.Value, CStr(cell.Value)
End If
Next cell
End If
Next ws
' ********************************enregistrer la liste des employés à partir de la colonne C ligne 3 de la feuille ("Heures employés")
On Error GoTo 0
j = 3
For i = 1 To Ommal.Count
WD.Cells(2, j) = Ommal(i)
j = j + 1
Next i
' ********************************* recherche des heures pour chaque employé
Dim dercol As Long
Dim h As Integer
dercol = WD.Cells(2, Cells.Columns.Count).End(xlToLeft).Column
With WD
.Activate
.Range("A2").Value = "Date"
.Range("B2").Value = "Num Semaine"
For b = 3 To dercol
h = 3
For Each ws In ThisWorkbook.Worksheets
If ws.Name Like "CLIENT*" Then
ws.Activate
On Error Resume Next
For Each cel In ws.Range("D9:D" & [D65000].End(xlUp).Row)
If cel.Value = .Cells(2, b) Then
.Cells(h, 1) = ws.Cells(cel.Row, 2)
.Cells(h, b) = ws.Cells(cel.Row, 6)
End If
h = h + 1
Next cel
End If
Next ws
Next b
End With
'********************remplir numéro de semaine
Dim dernligne As Long
dernligne = WD.Range("A" & Rows.Count).End(xlUp).Row
For n = 3 To dernligne
WD.Cells(n, 2).FormulaR1C1 = "=WEEKNUM(RC[-1])"
Next n
WD.Select
Application.ScreenUpdating = True
End Sub |
Partager