This one's a good challenge - slow down a macro!
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: This one's a good challenge - slow down a macro!

  1. #1
    New Member
    Join Date
    Apr 2002
    Posts
    8
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    Oh where do I start with this!

    I have a macro whose sole purpose is to open another workbook, select and copy a row of data and paste it into one central workbook. That's all it does - in all, the macro does this routine for about 150 separate workbooks (and puts the rows of data all into the one central workbook).

    My problem is this: Each of those 150 workbooks has links to another application and when each workbook is opened it takes a second or two for the links to update.

    Unfortunatley, my Macro is too quick and copies the row of data before it has had a chance to update (so it just copies a row of #N/A's and no data!!!)

    Ideally, I need my macro to open the workbook and then pause for say 3 seconds (so the workbook can have a chance to update its links) and THEN copy the data and carry on with the rest of the routine?

    Is there some sort of timer function or a pause and resume command for a macro?

    Anyone have any advice or suggestions to get round this problem?


  2. #2
    MrExcel MVP Mark O'Brien's Avatar
    Join Date
    Feb 2002
    Location
    Columbus, OH, USA
    Posts
    3,530
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Have a look at VBA help for "Wait", the example is pretty much what you're looking for. (I don't have Excel to bang something out for you today, sorry)

    150 times 3 seconds is 450 secs, that's a long time.

  3. #3
    Rest in Peace
    Join Date
    Feb 2002
    Posts
    1,582
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi Richard

    The OnTime Method should help, try

    Code:
    Private Sub Workbook_Open()
    Application.OnTime Now + TimeValue("00:00:05"), "CopyIt"
    End Sub

    Where "CopyIt" is your macro.


  4. #4
    New Member
    Join Date
    Apr 2002
    Posts
    8
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    Thanks Mark - I was searching in VBA help for "pause" "delay" "suspend" and everything else under the sun - except wait!!!

    Cheers!

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com