PDA

View Full Version : VBA Help, need this for school



bombaybom
10-21-2014, 01:23 AM
Hi,

I have problem to get this code to loop, it do copy ones but then stops, Plese Help!



Dim TimeToRun
Sub auto_open()
Call ScheduleCopyPriceOver
End Sub

Sub ScheduleCopyPriceOver()
TimeToRun = Now + TimeValue("00:00:01")
Application.OnTime TimeToRun, "CopyPriceOver"
End Sub

Sub CopyPriceOver()
Set mycell = Cells(65000, 3).End(xlUp).Offset(1, 0)
mycell.Value = Now
mycell.Offset(0, 1).Value = Range("D7").Value
Call ScheduleCopyPriceOver
End Sub

Sub auto_close()
On Error Resume Next
Application.OnTime TimeToRun, "CopyPriceOver", , False
End Sub

ashleyuk1984
10-21-2014, 01:44 AM
What exactly do you want the subroutine to do? I don't think it's necessary to have several subroutines like you currently have.
What do you want the end result to look like?

Can you provide any examples.

bombaybom
10-21-2014, 02:06 AM
Hi,

I whant to copy one cell so that i get the current shareprice every minut (in the code is it every sec but that is just for testing)

12419

mancubus
10-21-2014, 02:11 AM
an assignment?

bombaybom
10-21-2014, 02:29 AM
Hi

I need to get down the data to calculate how share prices moves over time. The only data i can get is daly but i need it to be on a shorter time frame.

But the scirpt stops after copy one cell. Then i need to start it agian.
I really need som help

Thanks in advance

bombaybom
10-21-2014, 03:04 AM
Hi,

I have solved it

Thx for the help :)

GTO
10-21-2014, 03:06 AM
Greetings bombaybom,


Thank you for being forthright in stating that this is for a school assignment.

Although giving you a solution forthwith would seem counter productive for your true education, I would suggest including a workbook attached. This way, you can better explain the problem, and we can, without giving an 'answer', guide you to discovering the answer for your assignment. In short - at least as far as I am concerned - you should be able to advise your teacher of this thread and be able to receive full credit for your developed solution. Does that make sense?

Mark

bombaybom
10-21-2014, 03:19 AM
HI Mark,

I understand that just give the right answer wood be counter produktive but somtimes you jsut need som guidens.

The school assignment was not to use VBA. It was to calculate equity prices. I just thought VBA was the best way to solve it.
Now I try to get my web queries to work. To bring it all together.

Chris