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
| Sub Compile_Data_Sheet_Facture()
Dim LRP1 As Byte, LRP2 As Byte, LRF1 As Byte, LRF2 As Byte
Dim TotHT As Single, TotTTC As Single
Application.ScreenUpdating = False
'MAJ TCD et copier données dans feuille "Facture"
With Sheets("Pivot")
.PivotTables("Facture1").PivotCache.Refresh
.PivotTables("Facture2").PivotCache.Refresh
LRP1 = .Cells(.Rows.Count, 1).End(xlUp).Row
LRP2 = .Cells(.Rows.Count, 4).End(xlUp).Row
.Range("A4:B" & LRP1).Copy Sheets("Facture").Range("T2")
.Range("D4:E" & LRP2).Copy Sheets("Facture").Range("W2")
End With
With Sheets("Facture")
LRF1 = .Cells(.Rows.Count, 20).End(xlUp).Row
LRF2 = .Cells(.Rows.Count, 23).End(xlUp).Row
TotHT = .Range("E2").Value
TotTTC = .Range("E4").Value
.Range("T" & LRF1).Offset(2, 0) = "Somme :"
.Range("W" & LRF2).Offset(2, 0) = "Somme :"
.Range("T" & LRF1).Offset(3, 0) = "Contrôle :"
.Range("W" & LRF2).Offset(3, 0) = "Contrôle :"
With .Range("U" & LRF1).Offset(2, 0)
.Formula = "=+SUM(R[-" & LRF1 & "]C:R[-2]C)"
.Value = .Value
End With
With .Range("X" & LRF2).Offset(2, 0)
.Formula = "=+SUM(R[-" & LRF2 & "]C:R[-2]C)"
.Value = .Value
End With
With .Range("U" & LRF1).Offset(3, 0)
.Formula = "=IF(R[-1]C-" & TotHT & "=0, ""OK"",""Erreur"")"
.Value = .Value
End With
End With
Application.CutCopyMode = False
Application.ScreenUpdating = True
MsgBox "Traitement des données effectué avec succès", vbInformation + vbOKOnly, "Calcul automatique"
End Sub |
Partager