++ Andrew_Coolman and oko1.

TIMTOWTDI (a very linear way without using the native abilities of a module (possibly use Win32::OLE::Const 'Microsoft Excel'; or similar):

#!usr/perl/bin use strict; use warnings; my $Formula = "=MAX(B499:AR499)"; #desired: "=MAX(B500:AR500)" my ($formula_begin, $therest) = split /\({1}/, $Formula; # ESCAPE the + open paren my ($cell1, $cell2) = split /:/, $Formula; my ($cell1a, $cell1b) = split /\(/, $cell1; my ($cell2a, $closeparen) = split /\)/,$cell2; # One way to get rid of + the trailing ')' so we can increment the number, later. print "First cell referenced: $cell1b, second cell referenced: $cell2a +\n\n"; $cell1b =~ /([A-Z]+)(\d+)/; my $cell1balpha = $1; my $cell1bdigits = $2; $cell2a =~ /([A-Z]+)(\d+)/; my $cell2aalpha = $1; my $cell2adigits = $2; ++$cell1bdigits; ++$cell2adigits; print "AFTER INCREMENT, first cell referenced: $cell1balpha" . $cell1b +digits . "; second cell referenced: $cell2aalpha" ."$cell2adigits\n\n +"; print "\tRefs adjusted formula: $formula_begin" . "($cell1balpha" . $c +ell1bdigits. ":$cell2aalpha" ."$cell2adigits" . ")\n";

Output: Refs adjusted formula: =MAX(B500:AR500)

This is not the recommended way but may serve to illustrate one way of dealing with the likes of cell references in OO's scalc or Excel.

Added plaudits to oko1, missing colon in last code item, output, and the missing "in" in last paragraph


In reply to Re: Win32::OLE Excel formula Copy by ww
in thread Win32::OLE Excel formula Copy by srivasva

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.