I am inserting a macro in a particular column, across three different worksheets in excel workbook. This is being done in a loop. In first sheet all the macros are inserted properly, but for next sheets, only few of the cells gets updated with macro.

The strange thing is when I debug the same program with stepwise execution, everything is disturbingly fine.

Monks please help.

UPDATES!!! The code bit

$active_cell->{FormulaR1C1} = $my_macro_expression; $active_cell->Select; $active_cell->Copy; $Sheet->Range($active_cell, $end_cell)->Select; $Sheet->Paste

UPDATES!!! The solution

while using different worksheets, script was not activating them before writting formula. Thats it.

UPDATES!!! Solution leads to another question

How the hell script was working fine in debugging mode without worksheet activation command????

In reply to Excel Macro Writting Issue by sachin_p_ganjare

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.