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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |