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
| Dim SpS As Worksheet, SpP As Range, valeur1 As Variant, valeur2 As Variant, decalage As Integer
Dim TblReport()
Dim Mailing()
TableName = "T_Reports"
TblReport = Range(TableName)
For i = 1 To UBound(TblReport)
If TblReport(i, 7) > Now And TblReport(i, 7) <= Now + 56 And TblReport(i, 10) = "Y" Then
Project_ID = TblReport(i, 1)
periodid = TblReport(i, 2)
Acronym_Range = Application.Match(Project_ID, Worksheets("Projects").Range("A:A"), 0)
Acronym = Worksheets("Projects").Cells(Acronym_Range, 3)
Set SpS = ThisWorkbook.Worksheets("Staff")
Set SpP = SpS.Range("A1:A" & SpS.Range("A" & Rows.Count).End(xlUp).row)
valeur1 = Project_ID
valeur2 = periodid
decalage = 7 '(de A à H)
ReDim Mailing(1 To 1) As Variant
With SpP
Set la = .Find(valeur1, LookIn:=xlValues)
If Not la Is Nothing Then
prem = la.Address
i = 1
Do
i = i + 1
If la.Offset(0, decalage) = valeur2 Then Mailing(i) = (SpS.Cells(la.row, 4) & "." & SpS.Cells(la.row, 3))
ReDim Preserve Mailing(1 To i)
Set la = .FindNext(la)
Loop While Not la Is Nothing And la.Address <> prem
End If
End With
End If
Next
MsgBox (Mailing(1)) |