Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Function/Procedure dependence & order of execution | Excel Programming | |||
Calling a procedure in a procedure | Excel Programming | |||
Calling a procedure in a procedure | Excel Programming | |||
Calling a procedure in a procedure | Excel Programming |