Shape Rotation continuously till change the shape value

  • Dear Team,


    I want to rotate my shape . My code is



    For rotating my shape i am using following code


    My condition is

    when ActiveSheet.Shapes("MIXER ON/OFF").TextFrame.Characters.Text = "ON" then my shape "Curved Down Arrow 314" should start rotating.


    When ActiveSheet.Shapes("MIXER ON/OFF").TextFrame.Characters.Text = "OFF" then it should stop rotating.


    I dont know how to apply my condition on this code.


    Can any one help me to solve this issue.


    I am attaching my file here for your reference.

  • if I understood correctly you want immediately stop rotation if the button switches to OFF

    Then you have to modify in the procedure Sub MIXER_6K1_ON_OFF() following part


    add

    Code
    1. If ws.Shapes("MIXER ON/OFF").TextFrame.Characters.Text = "OFF" Then Exit For

    in (shown below)

    Code
    1. ' Rotate clockwise
    2. For Ratio = 0.5 To 5 Step 0.02
    3. If ws.Shapes("MIXER ON/OFF").TextFrame.Characters.Text = "OFF" Then Exit For
    4. ' Calc the rotation angle in degrees
    5. phi = MinAngle + (MaxAngle - MinAngle) * Ratio
    6. ' Rotate shape
    7. .Rotation = phi
    8. ' Make pause
    9. t = Timer + 0.01: While Timer < t: DoEvents: Wend
    10. Next
  • this runs as long as you do not change the button to OFF