@mdmac
chapeau !
Suggestions:
- since you use separate macros, I'd store them in the codemodule of each worksheet. No macromodules required.
- instead of passing separate ranges you can pass the values of 1 range
- the number of variables can be reduced to 2 (a counter & an array)
- the number of loops can be reduced to 1
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("C2:C7")) Is Nothing Then M_SpringCoil Range("C2:C10").Value
End Sub
Sub M_SpringCoil(sn)
If ActiveSheet.Shapes.Count > 0 Then
ActiveSheet.Shapes.SelectAll
Selection.Delete
End If
For j = 2 To 4
sn(j, 1) = sn(j, 1) * sn(6, 1)
Next
sn(7, 1) = (sn(3, 1) ^ 2 + (sn(2, 1) / sn(1, 1)) ^ 2) ^ 0.5
sn(8, 1) = Application.Acos(sn(3, 1) / sn(7, 1)) * (180 / 3.14159)
For j = 1 To sn(1, 1)
sn(9, 1) = 20 + (j - 1) * (sn(2, 1) / sn(1, 1))
ActiveSheet.Shapes.AddShape 69, 200, sn(9, 1), sn(3, 1), sn(4, 1)
If j = sn(1, 1) Then Exit For
With ActiveSheet.Shapes.AddShape(69, 200 - 0.5 * (sn(7, 1) - sn(3, 1)), sn(9, 1) + (sn(2, 1) / sn(1, 1) / 2), sn(7, 1), sn(4, 1))
.IncrementRotation sn(8, 1)
.Fill.ForeColor.Brightness = -0.25
End With
Next
End Sub