Pete634
03-24-2009, 04:23 PM
Hi,
I've written two workbooks that contain different macro codes.
The first workbook with code (call it A) opens the second with code (call it B) and populates B with data from a third workbook (C) which has no code.
B could actually be any number of workbooks (in the particular environment I am using it this is 4), but that doesn't matter as B1, B2 etc are all clones from one master B.
Problem is this:
A won't work when B has macros (it fails when populating the data because of the code in B)
A works fine if B has no macros (ie an exact copy of B but without any macros)
B works fine with it's macros (so if I can get A to populate the B's with the data from C there would be no problem)
Is there any way I can turn off the macros in B when A is running?
As B has code attached to the open workbook event I initially disabled this with
If sheets(1).range("A2") = "" then
Exit Sub
end if
this worked fine (A2 has no value until data is installed)
I then tried a similar argument in my Private Sub Worksheet Change on sheet 1 of workbook B; (note I cleared the contents of A1 from the code in workbook A after opening it with the intention of putting the contents back in once the data population had finished)
If sheets(1).range("A1") = "" Then
Exit Sub
end if
but it kept skipping this completely and failing on the next lines of code.
Where am I going wrong? Is there a simple way to temporarily turn off code in B only whilst A runs?
Any help would be greatly appreciated.
Thanks
I've written two workbooks that contain different macro codes.
The first workbook with code (call it A) opens the second with code (call it B) and populates B with data from a third workbook (C) which has no code.
B could actually be any number of workbooks (in the particular environment I am using it this is 4), but that doesn't matter as B1, B2 etc are all clones from one master B.
Problem is this:
A won't work when B has macros (it fails when populating the data because of the code in B)
A works fine if B has no macros (ie an exact copy of B but without any macros)
B works fine with it's macros (so if I can get A to populate the B's with the data from C there would be no problem)
Is there any way I can turn off the macros in B when A is running?
As B has code attached to the open workbook event I initially disabled this with
If sheets(1).range("A2") = "" then
Exit Sub
end if
this worked fine (A2 has no value until data is installed)
I then tried a similar argument in my Private Sub Worksheet Change on sheet 1 of workbook B; (note I cleared the contents of A1 from the code in workbook A after opening it with the intention of putting the contents back in once the data population had finished)
If sheets(1).range("A1") = "" Then
Exit Sub
end if
but it kept skipping this completely and failing on the next lines of code.
Where am I going wrong? Is there a simple way to temporarily turn off code in B only whilst A runs?
Any help would be greatly appreciated.
Thanks