|
| Re: Macro not working |
 |
Sun, 27 Jan 2008 12:26:05 -070 |
lemoto wrote:
> I selected all the formula Cells and Insert|Named them as CalcBlock.
> Then I made the first command at MovePage: {ReCalc CalcBlock}
Yes, this by itself solves the macro's execution problem (at least in QP8).
Uli
|
| Post Reply
|
| Re: Macro not working |
 |
Sun, 27 Jan 2008 12:43:09 GMT |
Jeff:
from Uli:
> Basically, your code is fully functional except for the need to recalc your
> variable cells prior to executing the MovePage routine. That's the key
point
> that's somewhat buried in Roy's post.
I agree. I think I saw one error (in conception or execution) also. That is why
I recast the macro somewhat.
However: if you see other replies from me, please ignore them.
Weirdly, some lines failed to transfer to the post in the newsgroup or were
partially transferred, even in repeat postings. Finally, no doubt as a result of
irritation at this process, I managed to post an intermediate version of the
macro, which does nearly all that is intended, but does not put the Page Name in
the right Cell. Now I am victim of an intermittent QP bug - Names of Cells are
displayed incorrectly in the formula Cells. It will take me a little time to
sort this out.
Meantime, HTH:
I selected all the formula Cells and Insert|Named them as CalcBlock.
Then I made the first command at MovePage: {ReCalc CalcBlock}
--
Good wishes!
Roy Lewis
C_Tech volunteer
(UK)
|
| Post Reply
|
| Re: Macro not working |
 |
Sun, 27 Jan 2008 23:14:04 -070 |
lemoto wrote:
> However: if you see other replies from me, please ignore them.
> Weirdly, some lines failed to transfer to the post in the newsgroup or were
> partially transferred, even in repeat postings.
To boot, some of your prior posts in this thread have now mysteriously
disappeared.
> I managed to post an intermediate version of the
> macro, which does nearly all that is intended, but does not put the Page
Name in
> the right Cell. Now I am victim of an intermittent QP bug - Names of Cells
are
> displayed incorrectly in the formula Cells. It will take me a little time
to
> sort this out.
I'm wondering whether the problem you're encountering has anything to do with
what I just came across while trying to implement dynamic code, but at any rate
here's what I just discovered:
The automatic operation that QP seems to apply to macro code as it steps
through the command sequence line by line does NOT apply to DYNAMIC code. To
illustrate, here's dynamic code designed to produce Jeff's desired results. The
snippet below, which may not line up well in the newsreader, should copy as
range names and macro code into adjacent columns in QP:
'\U {Let SheetNum,5}
_CheckPage {Recalc SheetNum}
@CONCATENATE("{IF
",@INDEXTOLETTER(SheetNum-1),":A2=""""}"
;)
@CONCATENATE("{IF
",@INDEXTOLETTER(SheetNum-1),":A2=""NSF""}{Let
D:A",@COUNT(D:A8..A1000)+8,",",@INDEXTOLETTER(SheetNum-1),"}
")
{Let SheetNum,SheetNum+1}
{Branch _CheckPage}
SheetNum 5
Inducing an explicit recalc of the variable SheetNum is NOT enough to cause the
dynamic code (lines 3 and 4 of the macro) to update itself as the macro cycles
through each loop -- which quickly becomes obvious if running the macro in debug
mode, because the cell references don't change. However, if you name the entire
range of the macro AND the SheetNum variable as "MacroBlock", and you
change the
2nd line of the macro to {Recalc MacroBlock}, the dynamic code then DOES refresh
itself to reflect the new SheetNum value, and the macro works.
The lesson here (at least for me) is that dynamic code requires extra attention
in ensuring that it actually updates itself as you expect it would or should,
but seemingly it doesn't without explicit prompting.
FWIW,
Uli
|
| Post Reply
|
| Re: Macro not working |
 |
Mon, 28 Jan 2008 13:40:41 GMT |
Uli:
> To boot, some of your prior posts in this thread have now mysteriously
disappeared.
>
No mystery, just incompetence.-)}
I cancelled them, and in my previous post omitted to mention that I had done
this.
--
Good wishes!
Roy Lewis
C_Tech volunteer
(UK)
|
| Post Reply
|
| Re: Macro not working |
 |
Mon, 28 Jan 2008 13:40:42 GMT |
Uli:
> The automatic operation that QP seems to apply to macro code as it
steps
> through the command sequence line by line does NOT apply to DYNAMIC code.
I agree.
Just for interest: a dynamic command infelicity;
a knotty issue that needs special handling:
A dynamic command specifies which Row is to be referenced.
The effect of the command is to increment the Row number.
The dynamic command irritatingly does update, so that
(imaginary and inappropriate example, which would not in fact
create a Row change; I do not have an actual example to hand,
and I may not now have one at all)
{Let A99, "abc"}
becomes
{Let A100, "abc"}
When QP finishes reading the command, its pointer is at the end of
the command. When QP returns after processing the command,
the text has moved one position to the R. So QP continues
in the wrong place, and the macro fails.
=====
Side issue, detail - I wonder whether this hardcoded item should be so, or
whether
it should reflect the sheet currently addressed:
> @COUNT(D:A8..A1000)+8
=====
> I'm wondering whether the problem you're encountering has anything to do
with
> what I just came across while trying to implement dynamic code,
No; it can occur in regular formulae, as e.g: +C4 * SalesTax
where SalesTax may be replaced by some other Name. I have yet to find any
reliable
cause or any reliable pattern in the substitution.
--
Good wishes!
Roy Lewis
C_Tech volunteer
(UK)
|
| Post Reply
|
|
|