-1

Basically, the problem here is that I have a macro which changes the number of a specific cell and by doing that I change the numbers from three columns and when those numbers are changed my graphic starts to 'move'.

To be more specific, I have this graphic:

enter image description here

When I click on the button I have, the lines starts to move, and it looks like a mouth opening and closing.

The blue line corresponds to the first and second column values, whereas the red line is changed accordingly to the first and third column values:

enter image description here

Cell(B2) contains the number generated by this code:

    Sub OpenMouth()
    For i = 1 To 20
        Worksheets("Mouth").Cells(2, 2).Value = 0.1 + 2 * i / 20
        Calculate
        For j = 1 To 5000000
        Next j
        Next i
    End Sub

What I need to do is to prepare something similar: A graphic that by changing the numbers I have in columns A, B and C, it starts to move. The columns A, B and C will be changed by doing a simple loop in VBA, this loop will change one value, and the three columns will have a formula linked to this value, so they will have their values changed.

I've seen some really cool graphics, a ball rolling, a wheel moving, but I really don't have a clue of how to do this, I don't know how to do it.

Does anyone have an idea? Can anyone help me build a different graphic with a similar idea (of an object moving)?

This is another example, using the same logic:

enter image description here

Community
  • 1
  • 1
dekio
  • 810
  • 3
  • 16
  • 33

1 Answers1

1

Frankly, I would suggest rethinking your approach of creating a custom & complex animation in Excel. Excel just isn't the right tool for this.

I would use Javascript and embed a Internet Explorer control into Excel with the animation. The solution would work as follows:

  1. Press a button in Excel

  2. A VBA macro executes the animation by loading the Microsoft Web Browser control with a custom HTML file with your animation in Javascript. The animation is show in the MS Web Browser Control.

Drawing in Javascript

Here a simple tutorial: http://www.w3schools.com/html/html5_canvas.asp

Test your drawings here: http://www.codecademy.com/courses/web-beginner-en-SWM11/0/1

Microsoft Web Browser Control

https://msdn.microsoft.com/en-us/library/aa752040(v=vs.85).aspx

AnalystCave.com
  • 4,884
  • 2
  • 22
  • 30
  • I also don't think excel is the best tool for this, but that's the point. I want to do in excel, the task was given to me in excel. I know I can do it in a simple way, I'm almost sure... But I don't know how. – dekio May 28 '15 at 13:20
  • Excel 2013 disallows scriptable activeX controls. – John Alexiou May 28 '15 at 13:43