+ Reply to Thread
Results 1 to 12 of 12

refresh from web with delay

  1. #1
    Registered User
    Join Date
    09-16-2007
    Posts
    39

    refresh from web with delay

    Ok, I can download my data from the web. I can set it to download every so many minutes. But, I have to select run on my vb program to complete calculations and put data in correct format/sheets. I am trying to put a delay/timer in the program so it will refresh on itself and I will not have to keep selecting program run. If I put this in program it appears to refresh in a timely manner however I do not get any data on the sheets ? I have tried the wait routine and the if now = time + routine, both with no luck. ???

  2. #2
    Forum Contributor
    Join Date
    07-05-2007
    Location
    Lexington, MA
    Posts
    302
    You probably have a loop that checks for new downloads and does the update. But, that loop needs to give control back to Excel so it can operate in parallell.

    Look at the doc for the DoEvents function, and search the forum.
    FrankBoston is the pen name for Andrew Garland, Lexington MA

  3. #3
    Registered User
    Join Date
    09-16-2007
    Posts
    39
    well I am not sure where to put the doevents in this thing. Funny thing I can step through program using f8 with no problem but, when I put it in run, it stops at the delay routine ???

  4. #4
    Forum Contributor
    Join Date
    07-05-2007
    Location
    Lexington, MA
    Posts
    302
    You haven't posted any code, so I can't give detailed advice.
    The following post uses DoEvents.

    http://www.excelforum.com/showthread...light=doevents

  5. #5
    Registered User
    Join Date
    09-16-2007
    Posts
    39

    Arrow

    Please Login or Register  to view this content.
    This is the code i use to create a 59 second delay. I originally had the updatedata statement under the beep statement. Beep is just there to let me know the program has reached this point. The udatedata is routine used for refreshing from the web. I tried this with a nine second delay and it appears the updatedata routine is running but the sheet with refreshed data does not change and none of the calculations etc. that are supposed to be performed after updating (refreshing from web) take place either. I also tried it with Doevents in the wait routine. This did not work either.
    On another note, my son used to live in Walpole and golf with a fellow named Frank. You would not happen to be that Frank would you?
    Last edited by VBA Noob; 09-24-2007 at 02:02 PM.

  6. #6
    Registered User
    Join Date
    09-16-2007
    Posts
    39
    OK, This is the latest. I put doevents in front of the if statement in the routine. It now does the events but skips some of the procedures in the updatedata sub.
    I don't know how to put code in here correctly but this is some of the code.

    Please Login or Register  to view this content.
    This code runs but it does not put the refreshed data in sheet 1 and does not run the fraction sub.
    Last edited by VBA Noob; 09-24-2007 at 02:02 PM.

  7. #7
    Forum Contributor
    Join Date
    07-05-2007
    Location
    Lexington, MA
    Posts
    302
    Your problem depends on what calls what, and when.
    For this, I need to see entire pieces of code, or smaller whole examples that fail.

    You can "wrap" your code by using the following as needed.
    [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code]

    The '#' choice at the top of the Message box, when posting a reply, will insert [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] which is a slight help.

    You said
    This code runs but it does not put the refreshed data in sheet 1 and does not run the fraction sub.
    This is puzzling. How can the code "run" but not execute?

    Ordinarily, doing something to a cell, like activating it, will cause the
    display to update. Do you have Application.ScreenUpdating = off?

    -- FrankBoston is a pen name

  8. #8
    Registered User
    Join Date
    09-16-2007
    Posts
    39
    Thanks Frank,
    Just talked to my son, his golf partner lives in Gloucester. I guess the code does not run. I have made another revision putting the wait in front of the complete routine. and it still does not work. I really don't like posting the whole code here because you all will see what a green horn I really am. But I really want this to work so will post more code here.
    Please Login or Register  to view this content.
    I am getting the data from the internet to sheet1. i then covert the fractions to decimal figures and if conditions are met the data is pasted to another sheet. I can go through the complete procedure manually using f8 but if I try to run it automatically it does not show any updates on sheet 1 and does not calculate and so on. it does beep (G).
    Last edited by VBA Noob; 09-24-2007 at 03:15 PM.

  9. #9
    Forum Contributor
    Join Date
    07-05-2007
    Location
    Lexington, MA
    Posts
    302
    I've made some suggestions/changes to this code, as I was reviewing it.
    - I have changed some parts where repeated Select was used, basing
    the change on a temporary range 'rr'.
    - I lost track of where data is being pasted.
    Worksheet.Paste is used without a destination range, and so will paste
    to the current selected cells. Is this what you intend? My preference is to
    specifically identify areas that are pasted, to keep the code from changing
    what it does if the selection is changed by added code.
    - No display updates are made to the workbook while Application.Wait is
    in effect, but they should show after it returns, and you hear the beep.

    So, I don't see why the workbook is not updating, unless it is due to pasting new data to places that you didn't intend. This isn't much help.

    One effect of F8 code stepping is that Excel handles events between code executions, which may not be true when the code runs normally.

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    09-16-2007
    Posts
    39
    hello Frank,
    I am downloading tote board odds for horse races. I want to download the data once a minute. I want to store the data if it is between 15 and 3 minutes to post. I am currently storing different race tracks on different sheets. The sheets the data is being pasted to have pre-entered data on them in a specific format. This may explain the paste method I am using. I continue to collect/paste data all day (9 races) So i cannot designate a specific cell for pasting to. Hope I have clarified this some.

    the paste function I have set up works. It pastes to column A on the designated work sheet. (Sheet2). or which ever sheet is designated. After pasting the active cell is located for the next past. I have the sheets preformatted with data and this paste format puts the data in correct position for calculations on the receiving sheet. I can run this program automatic and it works correctly if i leave out the wait function. I click on refresh from the get data menu and then click on run in the macro menu. This works correctly and all data is pasted correctly and calculations are done correctly. I want to automate the downloads so I don't have to be sitting at computer doing all that clicking every minute.
    Thank you for your help, i don't know what i am doing.
    Last edited by newdude; 09-24-2007 at 07:09 PM.

  11. #11
    Forum Contributor
    Join Date
    07-05-2007
    Location
    Lexington, MA
    Posts
    302
    I have looked around on the forum and found this post about "Application.OnTime". It might help you.

    See http://www.excelforum.com/showthread...plication.Wait

  12. #12
    Registered User
    Join Date
    09-16-2007
    Posts
    39
    FrankBoston,
    I continued in my efforts and found a thread here regarding AfterRefresh. This had a link to an ms site with code. I installed code and it seems to be working now in the wee hours of the morning. I will set it up and try it real time tommorow . Thanks for your help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1