Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 390
Default Storing automatically updated data

I am looking for some help storing data that is automatically updated. I
recieve stock price information in Excel and want to customize it. I want to
store the high and the low for a given time period and have tried using the
following loop (my comments are noted in { }):
Sub Data_Test()
Worksheets("Strategy").Activate
Range("I54").Calculate {This is the price quote copied from another
sheet}
Range("I54").Select
Selection.Copy
Range("I55").Select
Selection.PasteSpecial Paste:=xlPasteValues {storing the initial price
to determine the high later}
Range("J55").Select
Selection.PasteSpecial Paste:=xlPasteValues {storing the initial price
to determine the low later}
Application.CutCopyMode = False
Do
Worksheets(5).Range("I54").Calculate {want to refresh data but
doesn't work during loop}
If Worksheets(5).Range("I54").value
Worksheets(5).Range("I55").value Then
Worksheets("Strategy").Activate
Range("I54").Select
Selection.Copy
Sheets("Strategy").Select
Range("I55").Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
End If
If Worksheets(5).Range("I54").value <
Worksheets(5).Range("J55").value Then
Worksheets("Strategy").Activate
Range("I54").Select
Selection.Copy
Sheets("Strategy").Select
Range("J55").Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
End If
Stop
Loop Until Time = TimeValue("10:48:00 AM")
End Sub

I believe the code is correct. However, the link for the external data does
not update when the loop is running. Is there any way to store the data that
is generated so I can determine the high and low prices between a certain
time frame? The method outlined above seems cumbersome, there must be a
better option.

Thanks,
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Storing automatically updated data

Your code could stand major revision such as
Range("I54").Select
Selection.Copy
Range("I55").Select
Selection.PasteSpecial Paste:=xlPasteValues

could be

Range("I55").value=Range("I54").value

but your problem is probably that you query is not waiting. You can do your
updating via macro with a .Refresh BackgroundQuery:=False line in the query
and then use a macro to get the values desired.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Bill" wrote in message
...
I am looking for some help storing data that is automatically updated. I
recieve stock price information in Excel and want to customize it. I want
to
store the high and the low for a given time period and have tried using
the
following loop (my comments are noted in { }):
Sub Data_Test()
Worksheets("Strategy").Activate
Range("I54").Calculate {This is the price quote copied from another
sheet}
Range("I54").Select
Selection.Copy
Range("I55").Select
Selection.PasteSpecial Paste:=xlPasteValues {storing the initial price
to determine the high later}
Range("J55").Select
Selection.PasteSpecial Paste:=xlPasteValues {storing the initial price
to determine the low later}
Application.CutCopyMode = False
Do
Worksheets(5).Range("I54").Calculate {want to refresh data but
doesn't work during loop}
If Worksheets(5).Range("I54").value
Worksheets(5).Range("I55").value Then
Worksheets("Strategy").Activate
Range("I54").Select
Selection.Copy
Sheets("Strategy").Select
Range("I55").Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
End If
If Worksheets(5).Range("I54").value <
Worksheets(5).Range("J55").value Then
Worksheets("Strategy").Activate
Range("I54").Select
Selection.Copy
Sheets("Strategy").Select
Range("J55").Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
End If
Stop
Loop Until Time = TimeValue("10:48:00 AM")
End Sub

I believe the code is correct. However, the link for the external data
does
not update when the loop is running. Is there any way to store the data
that
is generated so I can determine the high and low prices between a certain
time frame? The method outlined above seems cumbersome, there must be a
better option.

Thanks,


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatically insert time in excel but not automatically updated NeueN Excel Worksheet Functions 4 December 25th 08 07:29 AM
Plot Area Changes Automatically When Updated Jeff Gross Excel Programming 3 April 25th 08 04:43 PM
Automatically insert last updated date Marie Bayes Excel Discussion (Misc queries) 3 January 22nd 07 11:04 PM
date and time updated automatically Richard Excel Worksheet Functions 1 February 5th 06 04:48 AM
Removing data from an automatically updated chart Reallydumb Charts and Charting in Excel 0 August 16th 05 01:57 AM


All times are GMT +1. The time now is 08:45 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"