match in vba
First, you'd have to spell .worksheetfunction correct to even get close!
But I'd drop the .worksheetfunction completely.
dim res as variant
.....
res = application.match(someval, somerng, 0)
if iserror(res) then
'not found
else
'is found
end if
There's a difference between the way VBA uses application.match() and
application.worksheetfunction.match().
The first returns an error you can check with iserror().
The second causes a runtime error that you have to code around.
dim res as variant
....
on error resume next
res = application.worksheetfunction.match(...)
if err.number < 0 then
'no match
err.clear
else
'found a match
end if
on error goto 0
I find using application.match() easier.
mwam423 wrote:
greetings, am using Application.WorksheetFunction.Match, using 0 - for exact
match, comparing two ranges (one in sheet1, other sheet2). i want to
highlight the columns of range in sheet2 which are not included in range in
sheet1. running into problem, i think, because when there is column which is
not in sheet1 range the function returns value equivalent to "N/A". have
tried using:
Application.WorksheetFucntion.IsNA(WorksheetFuncti on.Match()) but can't get
this to work. any and all suggestions appreciated, thanks!
--
Dave Peterson
|