Bonjour à tous,
j'avance sur le sujet et ci-après la macro en question qui fonctionne sauf le countifs qui remonte une erreur d'execution 1004 :
Sub Import_dates()
Dim ModeRecalcul As Long
Application.ScreenUpdating = False
ModeRecalcul = Application.Calculation
' Réglage du recalcul sur mode manuel
Application.Calculation = xlCalculationManual
'********************************
'* DECLARATIONS DES VARIABLES *
'********************************
Dim i%, j%, Dls%, Dld%, Sem%, Col%, projet%, année%
Dim Ws As Worksheet, Wd As Worksheet
'********************************
'* INITIALISATION DES VARIABLES *
'********************************
Set Ws = Sheets("Extraction Pluri")
Set Wd = Sheets("Marché MT")
Dls = Ws.Range("A" & Rows.Count).End(xlUp).Row
Dld = Wd.Range("A" & Rows.Count).End(xlUp).Row
For j = 3 To Dld
For i = 3 To Dls
If Ws.Cells(i, 12).Value = Wd.Cells(j, 1).Value And Ws.Cells(i, 7) = "1R3721" Then
Wd.Cells(j, 8).Value = 1
ElseIf Ws.Cells(i, 12).Value = Wd.Cells(j, 1).Value And Ws.Cells(i, 7) = "2P3721" Then
Wd.Cells(j, 9).Value = 1
ElseIf Ws.Cells(i, 12).Value = Wd.Cells(j, 1).Value And Ws.Cells(i, 7) = "3R3621" Then
Wd.Cells(j, 10).Value = 1
ElseIf Ws.Cells(i, 12).Value = Wd.Cells(j, 1).Value And Ws.Cells(i, 7) = "4P3721" Then
Wd.Cells(j, 11).Value = 1
End If
Wd.Cells(j, 12) = Wd.Cells(j, 8) + Wd.Cells(j, 9) + Wd.Cells(j, 10) + Wd.Cells(j, 11)
Wd.Cells(j, 13) = Wd.Cells(j, 12) * Wd.Cells(j, 6)
Wd.Cells(j, 7) = WorksheetFunction.CountIfs(Wd.Cells(j, 1), Ws.Cells(i, 12), Ws.Cells(i, 11), "TEM", DatePart("yyyy", Wd.Cells(i, 8)), "2021")
Next i
Next j
For j = 3 To Dld
For i = 3 To Dls
If Wd.Cells(j, 5) = "TEM" Then
Wd.Cells(j, 14) = Wd.Cells(j, 13) * "41,5"
ElseIf Wd.Cells(j, 5) = "AT" Then
Wd.Cells(j, 14) = Wd.Cells(j, 13) * "53,6"
End If
Next i
Next j
Application.ScreenUpdating = True
' Rétablissement du mode de recalcul d'origine
Application.Calculation = ModeRecalcul
End Sub
l'idée est de trouver le nombre d'occurrence d'un OTM dans la feuille Ws suivant 3 critères:
- "TEM"
- l'année
- l'OTM
Merci de votre aide.
Cdt