Pour faire bref voilà la logique du code.
J'ai une macro qui effectue différents calculs à partir d'une plage de données (Range) et d'un entier.
Je dois, via un bouton, pouvoir dupliquer le tableau contenant les données et ajouter pour chaque nouvelle occurence un bouton pour pouvoir executer la macro précédent (calculs)
Voici le code en question
La macro calcul
Public Sub compute_delivery(my_cells As Range, market As Integer)
Dim...
Ligne1= Ligne2+1 'formules en réalité plus compliqué en réalité
Ligne2= LIgne3*1/2
...
End Sub
La partie ajout d'un bouton (partie délicate):
Sub Add_button_w_macro(PositionCell As Range, Txt As String, Data_macro As Range)
Const H As Integer = 51
Const W As Integer = 100
'
'
With ActiveSheet.Shapes.AddShape(msoShapeActionButtonCustom, PositionCell.Left + 6, PositionCell.Top + PositionCell.Height + 6, W, H)
With .Fill
.ForeColor.RGB = RGB(37, 64, 97)
.TwoColorGradient msoGradientHorizontal, 1
End With
With .TextFrame
.MarginBottom = 5
.MarginLeft = 5
.MarginRight = 5
.MarginTop = 5
.Characters.Text = Txt
'"Click here to" & Chr(10) & "realize schedule" & Chr(10) & " -MPR- "
.Characters.Font.Color = RGB(0, 0, 0)
.Characters.Font.Bold = True
.HorizontalAlignment = xlHAlignCenter
.VerticalAlignment = xlVAlignCenter
End With
.OnAction = "'compute_delivery " & "(" & """" & Data_macro & """" & ")'" 'marche bien avec un paramètre
.OnAction = "'compute_delivery (""Data_macro"",""1"")'" 'marche pas avec un 2eme
End With
End Sub