View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Procedure Run Order

The only thing that raises a flag is if you probably let your query run in
the background. You should change the setting so it runs in the foreground
and your code will wait for the query to complete.

--
Regards,
Tom Ogilvy


"Alastair MacFarlane" wrote in message
...
Tom,

Thanks for the reply Tom, but that is the way I have it,
enclosed within the Workbook_Open Event. If I run the
procedures separately with one after another pressing F5,
there is no problem. It only happens when the procedures
are called one after another from another procedure/Event.
This would indicate to me that the first routine has not
completed before the second has run.

The first procedure copies values and calculates values
based on data imported from an external source. The second
locks these values so the user cannot change them.

Any further thoughts and thanks once again for your
response.

Alastair


-----Original Message-----
Code is usually executed sequentially

so

Sub Main()
Call CreateDlyBankSht
Call LockWorkBook
End sub

would normally insure what you ask. If using that

approach doesn't work,
then you need to dig deeper into the working of your code

and the state of
your workbook to identify the problem.

--
Regards,
Tom Ogilvy


"Alastair MacFarlane"

wrote in message
...
Dear All,

I have two procedures which should run one after

another:

(a)Call CreateDlyBankSht - Sets up the workbook
(b)Call LockWorkBook - Locks the Workbook and certain
customisations.

I get an error stating that I cannot ammend cells

because
the cells are locked. It looks as though the second
procedure is being run before the first one is complete.

Is there a way of telling Excel to undertake the first
procedure and complete it before the second procedure is
run?

Thanks again...

Alastair MacFarlane



.