I'm far from sure what you want, but I'll try anyway. However, let me start by stating my assumptions.
"Sheet" means a sheet and not a workbook (file).
"if" indicates that you are interested only in a boolean. A single occurrence or a hundred makes no difference. Once the value has been found you are not interested in anything else.
"the same" refers to "value" and means that you are interested in the value returned and not in any formula that gives rise to it. You also want a precise match and do not have problems with the accuracy of internal storage of binary representations of numbers.
"another" means precisely one other sheet which is known to you in advance, rather than any other sheet.
Both sheets are in the same workbook.
The following code works for me. If you make the assignments in lines 11 and 13 the same, you will get "Found" printed.
use strict;
use warnings;
use Win32::OLE;
my $xl = Win32::OLE->new('Excel.Application');
$xl->{SheetsInNewWorkbook} = 2;
$xl->{Visible} = 1;
my $wb = $xl->Workbooks->Add;
my $cellSource = $wb->Sheets(1)->Cells(1,1);
$cellSource->{Value} = 1;
my $cellTarget = $wb->Sheets(2)->Cells(2,2);
$cellTarget->{Value} = 2;
my $addFound = $wb->Sheets(2)->Cells->Find({
What => $cellSource->{Value},
LookIn => -4163 #xlValues
});
if ($addFound) {print "Found\n"} else {print "Not found\n"}
Regards,
John Davies
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.