Salut Alerion,
Salut l'équipe,
voici quelque chose qui a l'air de vouloir fonctionner.
Déso, j'ai supprimé les formules pour laisser VBA arranger ses bidons !
- le calcul est global lors d'un passage d'année (pas effacer [B1]) ;
- le calcul est localisé à la ligne dont tu changes les valeurs en [I:J] ;
- les APOGEES calculées sont inscrites en [K], couleur blanche ;
- les images sont affichées en [K].
Mieux, je ne pense pas pouvoir faire...
Public Sub Apogée(ByVal iIdx%)
'
Dim oPic As Object, rCel As Range, tTab, iRow%, sRep$, sBottle1$, sBottle2$
'
Application.ScreenUpdating = False
'
On Error Resume Next
With Worksheets("CAVE")
iRow = .Range("A" & Rows.Count).End(xlUp).Row
tTab = .Range("I1:K" & iRow).Value
For x = IIf(iIdx = 0, 3, iIdx) To IIf(iIdx = 0, iRow, iIdx)
sRep = fctCalcul(CInt(tTab(x, 1)), CInt(tTab(x, 2)))
If sRep <> CStr(tTab(x, 3)) Then
sBottle1 = "Bottle" & tTab(x, 3) & "_" & x
.Shapes(sBottle1).Delete
tTab(x, 3) = sRep
sBottle1 = "Bottle" & sRep
Set oPic = Worksheets("SHAPES").Shapes(sBottle1)
oPic.Copy
.Paste Destination:=.Range("K" & x)
sBottle1 = "Bottle" & sRep
sBottle2 = "Bottle" & sRep & "_" & x
.Shapes(sBottle1).Name = sBottle2
Set oPic = .Shapes(sBottle2)
Set rCel = .Range("K" & x)
With oPic
.Top = rCel.Top + 1
.Left = rCel.Left + (rCel.Width / 3)
End With
End If
Next
.Range("I1:K" & iRow).Value = tTab
.Columns.AutoFit
.[A1].Select
End With
On Error GoTo 0
'
Application.ScreenUpdating = True
'
End Sub
A+