Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50026

How to pause a macro whilst letting a web query finish and then resume macro

$
0
0
I am very new to office 2010 excel vba so please keep your answers simple.
I have a list of films starting at Cells(i, j) ( which is B12) and going downwards.
I have a web query setup that automatically gets film information from the web & puts it into cell AC60 & AC64 as soon as I enter the film title in B1.
So what the code does is gets the film title & pastes it to B1 which starts the web query, then it copies some stuff from the web query info & pastes it to 2 other cells, then it grabs the next film title etc etc.

But it takes approx 30 seconds for the web query to finish but the macro doesn't wait for this it just carries on.

I have tried using the wait function but it also stops the web query.

Is there a way of pausing the macro whilst still letting the web query work?

I've wasted a whole weekend on this, it's the best way to learn but enough is enough and I need help.

Here's the code:


Sub GetFilmTitleAndData()
'
' GetFilmTitleAndData Macro
'
'
Dim i As Long
Dim j As Integer
i = 12
j = 2
Do
'
'
Sheet1.Cells(i, j).Select
Selection.Copy
Range("B1").Select
ActiveSheet.Paste
'
'Application.Wait (Now + TimeValue("0:00:40"))
': Application.OnTime Now + TimeValue("00:00:40"), "PasteFilm"
'
'
Range("AC60").Select
Selection.Copy
Sheet1.Cells(i, j + 4).Select
ActiveSheet.Paste
Range("AC64").Select
Application.CutCopyMode = False
Selection.Copy
Sheet1.Cells(i, j + 5).Select
ActiveSheet.Paste
'
'
i = i + 1
Loop Until Sheet1.Cells(i, j).Value = ""
End Sub

Viewing all articles
Browse latest Browse all 50026

Trending Articles