View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rob Bovey Rob Bovey is offline
external usenet poster
 
Posts: 811
Default Can't Get Match Function to Use on Array

"ExcelMonkey" wrote in message
...
Why is the line of code not trapping the Error and generaing a TRUE for my
ISERROR statement with my current address?


When you use Excel worksheet functions off the
Application.WorksheetFunction object and the function being used returns an
error, the WorksheetFunction object throws a VBA error. If you want the
function to just return an error value that you can check, eliminate the
WorksheetFunction object and just use Application.Match (you won't get
autocomplete in the VB editor, but it will work just fine).

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm

esI have loaded a bunch of cell address into a 1D array. I am now
checking a
current cell address to see if it is in the array of preloaded address
using
a MATCH function. If it is not in the array the ISERROR function wrapped
around the MATCH should be TRUE. The line of code below is failing with a
1004 Error ("Unable to get Match property of the worksheet function class"

If Not IsError(Application.WorksheetFunction.Match(cell.P arent.Name &
"!" & cell.Address, UniqueCellAddressArray3, 0) - 1) Then
'Do something.......................
Else

When I check in my immediate window I get:
?cell.Parent.Name & "!" & cell.Address
Colour Legend!$E$2

I have also checked the array and it is in fact loaded with data:

?UniqueCellAddressArray3(1)
Unique Formulas!$D$2

And when I check the value that I know exists in the array I get an
answer:

?Application.WorksheetFunction.Match("Unique Formulas!$D$2",
UniqueCellAddressArray3, 0) - 1
1

Why is the line of code not trapping the Error and generaing a TRUE for my
ISERROR statement with my current address?

Thanks