Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default "Pausing" a macro for recalculation

I've posted this in the .misc group, but was advised to try my luck
here.

I have a workbook containing several sheets. In one of them there's
a list of organizational units. I've written a macro that grabs
selected unit identifiers from the sheet "F Units", copies them one
by one to a cell called Filter, and prints sheets with diagrams and
statistics for each of the units.

The procedure sometimes partly fails, as the filter isn't applied
to the statistics sheet. I guess this happens because the sheets
are printed before Excel finishes recalculating. If this is true, I
believe I can prevent the error by adding a "Wait" command, halting
the printing process for something like 3 seconds.

How can I do this? (Part of) the macro appears below.

---

Sub Print_selected_C_and_D()

For Each cell_in_loop In Selection
Set TargetSheet = Sheets("C Diagram")
TargetSheet.Range("Filter").Value = ActiveCell.Value
Sheets(Array("C Diagram", "D Statistics")).Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("F Units").Activate
ActiveCell.Offset(1, 0).Range("A1").Select
Next

---

Richard
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default "Pausing" a macro for recalculation

Two ways I have used after being told about them from kind people on the
newsgroup



For whole seconds delay use "wait"



Application.Wait Now() + TimeValue("00:00:03")



'Put it before the Next Command







If you need half a second then put the following at the top of the module



Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)



And then the following in your code where you want the pause



Sleep 500







  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default "Pausing" a macro for recalculation

Thanks, David -
just what I was loking for.

Regards,
Richard

"David Adamson" wrote in
:

Two ways I have used after being told about them from kind
people on the newsgroup

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
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
pausing a "save as" macro mocc Excel Discussion (Misc queries) 1 May 6th 08 02:36 AM
Macro to concatenate into "B1" B2 thru B"x" based on new data in "Col A" Dennis Excel Discussion (Misc queries) 0 July 17th 06 02:38 PM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM
prevent recalculation of random data except in a "Calculate" macro matt dunbar Excel Programming 1 December 10th 03 01:02 PM


All times are GMT +1. The time now is 03:39 AM.

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

About Us

"It's about Microsoft Excel"