Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / September 2006

Tip: Looking for answers? Try searching our database.

VBA Code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Preacher Man - 30 Aug 2006 23:21 GMT
I have a seeming simple task that I can't figure out.

I have a macro set up to refresh a query and then do some copying and
pasting of cells.
What code can I use to tell the macro to wait until the query is finished
refreshing until it does the copy and paste?

Here is the simple code.

Sub GetData()
ThisWorkbook.RefreshAll

' I need the following code to be run after the refresh is finished'
Range("J5").Select
   Selection.Copy
   Range("J6:J65000").Select
   ActiveSheet.Paste
   Application.CutCopyMode = False
   ActiveWindow.LargeScroll ToRight:=-1
   Range("D1").Select

End Sub
Jean-Guy Marcil - 31 Aug 2006 01:47 GMT
Preacher Man was telling us:
Preacher Man nous racontait que :

> I have a seeming simple task that I can't figure out.
>
[quoted text clipped - 18 lines]
>
> End Sub

This is a word.vba group, not an Excel one.
Try:
   excel.programming

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Gary''s Student - 01 Sep 2006 18:29 GMT
Objects that have the BackgroundQuery property set to True are refreshed in
the background.  You need to set them to false.  That way the VBA will wait
until the refresh completes.

Gary's Student

> I have a seeming simple task that I can't figure out.
>
[quoted text clipped - 18 lines]
>
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.