LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default Comparing Different Sized Arrays

I have two arrays. Array1 is 2D. The array2 is 1D.
Array2 has a subset of the values from array1. As such
it will always have fewer rows than Array1. I am checking
to see which values from the array1 are actually in the
array2. I am using a Match statment. The Match
statement will register when a match is found and put 0
in the second column of the first array. However when a
match is not found the code fails. This is because the
array2 will always have fewer rows then array1 as it is
always a subset of the first. I put in a If Not IsError
stmt thinking that this would allow the code to
progress. However it is not working. I keep getting an
Error 1004 "Unable to get the Match property of the
worksheet function class. It fails when X = 6.


For X = 1 To 6
Z = Application.WorksheetFunction.Match(Array1(0, X -
1), Array2, 0)
If Not IsError(Z) Then
Array1(1, X - 1) = 0
Else:
Array1(1, X - 1) = 1
End If
Debug.Print Array1(0, X - 1) & " " & Array1(1, X - 1)
& " "; Z
Next

The immediate window shows:

Sheet1 0
Sheet2 0
Sheet3 0
Sheet4 0
Sheet5 0

I want it to show:

Sheet1 0
Sheet2 0
Sheet3 0
Sheet4 0
Sheet5 0
Sheet6 1

Is my IsError statement not the right approach here?

Thanks

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use linest with variably sized data arrays? [email protected] Excel Worksheet Functions 0 April 13th 05 04:56 PM
Comparing Arrays KL Excel Worksheet Functions 9 December 3rd 04 08:58 PM
Comparing to Arrays [email protected] Excel Programming 1 August 31st 04 08:47 PM
Comparing to Arrays [email protected] Excel Programming 0 August 31st 04 07:41 PM
Printing a legal sized document on letter sized paper Paula O. Excel Programming 0 February 2nd 04 06:55 PM


All times are GMT +1. The time now is 05:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"