BoixosNois, pierre.jy, le forum,
J'ai corrigé 4 lignes ... Pour les identifiées, j'ai ajouté à la fin ' Corrigé ICI
Private Sub Worksheet_Activate()
Dim Données As Collection, TS(), EOTP As SsGroup, LS As Long, Détail, Plg As Range
Rem. —— Première Partie
Set Données = GroupOrg(PlgUti(Feuil01.[A8]), 12)
ReDim TS(1 To Données.Count, 1 To 2)
For Each EOTP In Données
LS = LS + 1
TS(LS, 1) = EOTP.Id
For Each Détail In EOTP.Contenu
TS(LS, 2) = TS(LS, 2) + Détail(10)
Next Détail, EOTP
ValPlgAju(Me.[RécapMatos]) = TS
Me.Rows(8).Resize(5000).RowHeight = Me.Rows(7).RowHeight
Me.[RécapMatos].Cells(LS + 1, 2).Resize(, 1).FormulaR1C1 = "=SUM(R7C:R[-1]C)"
With LignesAjustées(Feuil03.Rows(8), LS)
.Columns("L").Value = WorksheetFunction.Index(TS, 0, 1)
.Columns("H").Value = WorksheetFunction.Index(TS, 0, 2)
.Columns("A").FormulaR1C1 = "=10*ROW()-70"
.Columns("A").Value = .Columns("A").Value
End With
LS = 0
Dim j As Long
Dim N As Long
Dim dSommeBrute As Double 'somme des montants non arrondis
Dim dSommeArrondis As Double 'somme des montants arrondis
For j = 8 To N
'colonne H : arrondi
Cells(j, 8) = Round(Cells(N + 4, 12).Value * Cells(j, 15).Value, 2) ' Correction ICI
'somme des montants non arrondis
dSommeBrute = dSommeBrute + Cells(N + 4, 12).Value * Cells(j, 15).Value ' Correction ICI
'somme des montants arrondis
dSommeArrondis = dSommeArrondis + Round(Cells(N + 4, 12).Value * Cells(j, 15).Value, 2) ' Correction ICI
Next j
'si écart : réajuste le premier montant (H6)
dSommeArrondis = Round(dSommeArrondis, 2)
dSommeBrute = Round(dSommeBrute, 2)
If dSommeArrondis <> dSommeBrute Then
'ré-arrondit sinon écart de 10E-10
Range("H6").Value = Round(Range("H6").Value + dSommeBrute - dSommeArrondis, 2) ' Correction ICI
End If
suite:
'Supprimer ligne si colonnes H ou D vides
Dim oda, f, ln, nCol
On Error Resume Next
Application.ScreenUpdating = False
oda = Array(Sheets("ODA MATOS"))
For Each f In oda
If f.Name = "ODA MATOS" Then
nCol = "H"
Else
nCol = "D"
End If
For ln = f.Range(nCol & Rows.Count).End(xlUp).Row - 4 To 7 Step -1
If f.Range(nCol & ln) = 0 Or IsEmpty(f.Range(nCol & ln)) Then
f.Rows(ln).Delete shift:=xlUp
End If
Next ln
Next f
End Sub
LaCéline