Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Application wait question

I'm having some issues with pausing a macro to allow data to load. I have a
table created from an imported web query, and my macro refreshes the query
and then makes some adjustments to the new data:

Sub NewData()

'Refresh part
Range("e44").Select
Selection.QueryTable.Refresh

'line X

'Adjust part
Range("ColA").Select
Selection.Copy
Range("ColB").Select
Selection.PasteSpecial Paste:=xlPasteValues
Range("ColB").Select
Selection.Replace What:="~*", Replacement:=""
End sub

For line X, I have tried:
Application.Wait TimeSerial(Hour(Now()), Minute(Now()), Second(Now()) + 10)
and
Application.Wait Now + TimeValue("00:00:10")
and have also made use of:
Public Function Delay()
y = Timer + 10
Do While Timer < y
DoEvents
Loop
End Function

However, when I run the macro, only the Refresh part works even though it
takes 10 seconds to run, but when I run the macro again, the Adjust part then
works. Also, when I step through the data, the pause activates, and
everything seems to work. Any ideas would be appreciated. thanks.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default Application wait question

Just a thought... still not sure if this will work... but have you tried
separating the macros? Please see example below.


Mark Ivey



Sub NewData()

'Refresh part
Range("e44").Select
Selection.QueryTable.Refresh

' Call the second macro
Second_Macro

End Sub


Sub Second_Macro()

'Adjust part
Range("ColA").Select
Selection.Copy
Range("ColB").Select
Selection.PasteSpecial Paste:=xlPasteValues
Range("ColB").Select
Selection.Replace What:="~*", Replacement:=""
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Application wait question

Mark - thanks for responding. However, I had already tried that, and
unfortunately it didn't work either.

"Mark Ivey" wrote:

Just a thought... still not sure if this will work... but have you tried
separating the macros? Please see example below.


Mark Ivey



Sub NewData()

'Refresh part
Range("e44").Select
Selection.QueryTable.Refresh

' Call the second macro
Second_Macro

End Sub


Sub Second_Macro()

'Adjust part
Range("ColA").Select
Selection.Copy
Range("ColB").Select
Selection.PasteSpecial Paste:=xlPasteValues
Range("ColB").Select
Selection.Replace What:="~*", Replacement:=""
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Application wait question

"Graeme" wrote in message
...

I'm having some issues with pausing a macro to allow data to load. I have

a
table created from an imported web query, and my macro refreshes the query
and then makes some adjustments to the new data:

Sub NewData()

'Refresh part
Range("e44").Select
Selection.QueryTable.Refresh


Does this work?

Selection.QueryTable.Refresh (False)


--
roger


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Application wait question

This worked perfectly! Thank you.

"roger" wrote:

"Graeme" wrote in message
...

I'm having some issues with pausing a macro to allow data to load. I have

a
table created from an imported web query, and my macro refreshes the query
and then makes some adjustments to the new data:

Sub NewData()

'Refresh part
Range("e44").Select
Selection.QueryTable.Refresh


Does this work?

Selection.QueryTable.Refresh (False)


--
roger



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
Application.wait... won't! Peter Rooney Excel Programming 12 November 17th 06 04:31 AM
Please help with Application.Wait ( ) Steve[_80_] Excel Programming 2 January 6th 06 01:23 PM
pause vba action without using Application.Wait? [email protected] Excel Programming 2 December 21st 05 07:12 PM
Different syntax for Application.Wait Desert Piranha[_19_] Excel Programming 3 December 16th 05 12:13 PM
application.wait help flowtester Excel Programming 10 December 4th 05 03:47 PM


All times are GMT +1. The time now is 11:21 PM.

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

About Us

"It's about Microsoft Excel"