Sub copiePV()
Dim Cel As Range, C As Range
Dim LigneAjout As Long
colCible = Application.Match(Sheets("BALANCE A INTEGRER").[G5], Sheets("Rapport").[7:7], 0) 'trouver la colonne du mois en G5
If IsError(colCible) Then Exit Sub 'si mois en G5 pas renseigné ou mal orthographié
Application.ScreenUpdating = False
For Each Cel In Sheets("BALANCE A INTEGRER").Range("A9:A" & Sheets("BALANCE A INTEGRER").Range("A" & Rows.Count).End(xlUp).Row)
Set C = Sheets("RAPPORT").Columns(1).Find(Cel, , xlValues, xlWhole)
If Not C Is Nothing Then
Cel.Offset(0, 6).Copy
Sheets("RAPPORT").Cells(C.Row, colCible).PasteSpecial (xlPasteValues)
Else
LigneAjout = Sheets("RAPPORT").Range("A" & Rows.Count).End(xlUp).Row + 1
Cel.Resize(, 5).Copy
Sheets("RAPPORT").Range("A" & LigneAjout).PasteSpecial (xlPasteValues)
Cel.Offset(0, 6).Copy
Sheets("RAPPORT").Cells(LigneAjout, colCible).PasteSpecial (xlPasteValues)
End If
Next Cel
Application.CutCopyMode = False
Application.ScreenUpdating = True
Set C = Nothing
End Sub