Create a Macro to give movement to a graphic.

K

kathymercado

Hi everyone,

I need to create a macro that allows me to make a graphic to move.

The graphic is about wave movement.

The problem is stated like this..

I have 2 columns. x and y.. The data they contain is all in negative
numbers ranging from -1,51 to -0,39 for column x and backwards for y.
The X column is the time column...
The macro idea is to make the graphic to change every 2 minutes in a
ranging time of 1-10 minutes.
In the bottom of the X column after all the negatives numbers, a cell
with the number 2 is shown.
And at the top of the Y column before all the negative numbers there
is another cell with the number 2. In top of that.

Here it is.. This is the data I guess I should use in order to create
the macro:

Tiempo ?
X 2
-1,51 -0,38
-1,50 -0,39
-1,49 -0,40
-1,48 -0,41
-1,47 -0,42
-1,46 -0,43
-1,45 -0,44
-1,44 -0,45
-1,43 -0,46
-1,41 -0,47
-1,41 -0,48
-1,40 -0,49
-1,39 -0,50
-1,38 -0,51
-1,37 -0,52
-1,36 -0,53
-1,35 -0,54
-1,34 -0,55
-1,33 -0,56
-1,32 -0,57
-1,31 -0,58
-1,30 -0,59
-1,29 -0,60
-1,28 -0,61
-1,27 -0,62
-1,26 -0,63
-1,25 -0,64
-1,24 -0,65
-1,23 -0,66
-1,22 -0,67
-1,21 -0,68
-1,20 -0,69
-1,19 -0,70
-1,18 -0,71
-1,17 -0,72
-1,16 -0,73
-1,15 -0,74
-1,14 -0,75
-1,13 -0,76
-1,12 -0,77
-1,11 -0,78
-1,10 -0,79
-1,09 -0,80
-1,08 -0,81
-1,07 -0,82
-1,06 -0,83
-1,05 -0,84
-1,04 -0,85
-1,03 -0,86
-1,02 -0,87
-1,01 -0,88
-1,00 -0,89
-0,99 -0,90
-0,98 -0,91
-0,97 -0,92
-0,96 -0,93
-0,95 -0,94
-0,94 -0,95
-0,93 -0,96
-0,92 -0,97
-0,91 -0,98
-0,90 -0,99
-0,89 -1,00
-0,88 -1,01
-0,87 -1,02
-0,86 -1,03
-0,85 -1,04
-0,84 -1,05
-0,83 -1,06
-0,82 -1,07
-0,81 -1,08
-0,80 -1,09
-0,79 -1,10
-0,78 -1,11
-0,77 -1,12
-0,76 -1,13
-0,75 -1,14
-0,74 -1,15
-0,73 -1,16
-0,72 -1,17
-0,71 -1,18
-0,70 -1,19
-0,69 -1,20
-0,68 -1,21
-0,67 -1,22
-0,66 -1,23
-0,65 -1,24
-0,64 -1,25
-0,63 -1,26
-0,62 -1,27
-0,61 -1,28
-0,60 -1,29
-0,59 -1,30
-0,58 -1,31
-0,57 -1,32
-0,56 -1,33
-0,55 -1,34
-0,54 -1,35
-0,53 -1,36
-0,52 -1,37
-0,51 -1,38
-0,50 -1,39
-0,49 -1,40
-0,48 -1,41
-0,47 -1,42
-0,46 -1,43
-0,45 -1,44
-0,44 -1,45
-0,43 -1,46
-0,42 -1,47
-0,41 -1,48
-0,40 -1,49
-0,39 -1,50
2 blank

The graphic is made in a lines graphic and it shows a single wave.

Would anyone help me to make that wave to move using a macro?

Help please.

Waiting for your prompt reply.

Kathy
 
J

JE McGimpsey

Your question is somewhat lacking in detail, but perhaps this could give
you a start:

Public Sub MoveGraphic()
Const nXSTART As Long = 400
Const nYSTART As Long = 400
Const xSCALE As Long = 200
Const ySCALE As Long = 200
Const dINTERVAL As Double = #0:2:0#
Const sSHAPENAME As String = "MyGraphic"

Static nRow As Long
Static shGraphic As Shape
Dim bStop As Boolean

If nRow = 0 Then nRow = 2
With ActiveSheet
If shGraphic Is Nothing Then _
Set shGraphic = .Shapes(sSHAPENAME)
With .Cells(nRow, 1)
bStop = .Value > 0
If Not bStop Then
shGraphic.Left = nXSTART + .Value * xSCALE
shGraphic.Top = nYSTART + .Offset(0, 1).Value * ySCALE
Application.OnTime Now + dINTERVAL, "MoveGraphic"
nRow = nRow + 1
End If
End With
End With
End Sub

Adjust the constants as desired.

This starts at row 2, and continues until the X column has a positive
number.

I'm not sure what "change every 2 minutes in a ranging time of 1-10
minutes" means, so the macro changes the position of the graphic every 2
minutes.
 
K

kathymercado

Thanks GE, for the help.

I tried to run de Macro you just gave me but it gave me an error; it
is the following:

'-2147024809 (80070057)' in execution time.

Thruth is I don't have much idea about macros besides all the info I
have been gathering for the last 2 days. Reading manuals and
everything I can get regarding the issue.

The idea is to be able to get a job. I am applying to be a BILINGUAL
EXECUTIVE ASSISTANT, here at Citibank in Colombia. Unfortunately it
seems that almost no one here in Colombia knows how to run this type
of application.

They made me an advance excel test. It had 3 points. I solve the 2
firsts without a problem, but I wasn't able to made the 3rd. The one
with the Macro I tried to describe in here.

Could you send me your email address? and I will send you the info I
can recall from the test they gave me.

I really appreciate your help since it seems you are until now the
only person who has been able to give me at least a light on this
matter.
No one I know has been able to help me including some system
engineers.

Thanks for all your help,

Kathy
 
K

kathymercado

Anyone else, any ideas??

Thanks JE, for the help.

I tried to run de Macro you just gave me but it gave me an error; it
is the following:

'-2147024809 (80070057)' in execution time.

Thruth is I don't have much idea about macros besides all the info I
have been gathering for the last 2 days. Reading manuals and
everything I can get regarding the issue.

The idea is to be able to get a job. I am applying to be a BILINGUAL
EXECUTIVE ASSISTANT, here at Citibank in Colombia. Unfortunately it
seems that almost no one here in Colombia knows how to run this type
of application.

They made me an advance excel test. It had 3 points. I solve the 2
firsts without a problem, but I wasn't able to made the 3rd. The one
with the Macro I tried to describe in here.

Could you send me your email address? and I will send you the info I
can recall from the test they gave me.

I really appreciate your help since it seems you are until now the
only person who has been able to give me at least a light on this
matter.
No one I know has been able to help me including some system
engineers.

Thanks for all your help,

Kathy
 
J

JE McGimpsey

Since you didn't post any additional information, it's not as likely
that someone else will be able to troubleshoot the problem (though it
may happen...).

The error you cite is not very helpful. Do you get the option to
"Debug"? If so, when you're switched to the VBE, what line of code is
highlighted?

Did you change the constants to suit your circumstances?
 
Top