Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Procedure Run Order

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Procedure Run Order

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Procedure Run Order

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



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
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



.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Procedure Run Order

Thanks again Tom,

The problem seemed to be the order I ran the following
code:

ActiveWorkbook.Protect "TEST", Structu=True,
Windows:=False
ActiveSheet.Protect "TEST", DrawingObjects:=True,
Contents:=True, Scenarios:=True

If I protected the sheet prior to activesheet the workbook
I would get an error, but when the other way round I would
get no error. Why? I don't know.

Thanks Tom


-----Original Message-----
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



.



.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Procedure Run Order


Works either way for me. Tested both as a standalone code module and in the
workbook_open event of the workbook.

--
Regards,
Tom Ogilvy





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

The problem seemed to be the order I ran the following
code:

ActiveWorkbook.Protect "TEST", Structu=True,
Windows:=False
ActiveSheet.Protect "TEST", DrawingObjects:=True,
Contents:=True, Scenarios:=True

If I protected the sheet prior to activesheet the workbook
I would get an error, but when the other way round I would
get no error. Why? I don't know.

Thanks Tom


-----Original Message-----
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



.



.



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
Function/Procedure dependence & order of execution Jon L Excel Programming 1 October 3rd 04 10:06 AM
Calling a procedure in a procedure Norman Jones Excel Programming 8 August 20th 04 07:53 PM
Calling a procedure in a procedure N10 Excel Programming 2 August 18th 04 12:49 AM
Calling a procedure in a procedure Don Guillett[_4_] Excel Programming 1 August 17th 04 11:31 PM


All times are GMT +1. The time now is 12:20 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"