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 / Excel / New Users / April 2008

Tip: Looking for answers? Try searching our database.

Code skips refresh all

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
F Jones - 24 Apr 2008 13:49 GMT
Hello

I have posted my issue before but a colleague has the same issue. We have
macros which run some code including a refreshall. The refeshall does not
complete before the macro goes to the next step and this causes it to crash
or not work correctly.

what step could i put in the code so that it waits until the refresh is
complete before going onto the next bit. a time break would not work because
the refresh can take different amounts of time depending on where you are
refreshing it.

my code:

Sub Refresh_all_Button_Click()
   ActiveWorkbook.RefreshAll
   MsgBox ("Refresh is complete")
   Range("k2").Select
   ActiveCell.FormulaR1C1 = "=TODAY()"
End Sub

Thanks
Signature

F Jones

Gary''s Student - 24 Apr 2008 14:15 GMT
Try putting a doevents after the refresh:

Sub Refresh_all_Button_Click()
ActiveWorkbook.RefreshAll
DoEvents
MsgBox ("Refresh is complete")
Range("k2").Select
ActiveCell.FormulaR1C1 = "=TODAY()"
End Sub

This may give the worksheet time to "catch up" before the rest of the macro
executes.
Signature

Gary''s Student - gsnu200781

> Hello
>
[quoted text clipped - 18 lines]
>
> Thanks
F Jones - 24 Apr 2008 14:45 GMT
Still the same issue... the message box pops up almost straight away.
Signature

F Jones

> Try putting a doevents after the refresh:
>
[quoted text clipped - 31 lines]
> >
> > Thanks
Dave Peterson - 24 Apr 2008 14:17 GMT
What are you refreshing?

Pivottables or Queries?

If queries, do you have the "enable background refresh" turned on?

If yes, then maybe turn them off (all of them) would help.

> Hello
>
[quoted text clipped - 20 lines]
> --
> F Jones

Signature

Dave Peterson

F Jones - 24 Apr 2008 15:01 GMT
Its a table based on OLAP cubes so queries rather than pivot tables.
How do I switch off/on "Enable background refresh" in Excel 2007?

Signature

F Jones

> What are you refreshing?
>
[quoted text clipped - 28 lines]
> > --
> > F Jones
Dave Peterson - 24 Apr 2008 18:20 GMT
Try rightclicking on the query table cell and choosing properties.

That's the way it worked in xl2003.

> Its a table based on OLAP cubes so queries rather than pivot tables.
> How do I switch off/on "Enable background refresh" in Excel 2007?
[quoted text clipped - 38 lines]
> >
> > Dave Peterson

Signature

Dave Peterson


Rate this thread:






 
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.