Thread: array question
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Charlie Charlie is offline
external usenet poster
 
Posts: 703
Default array question

Try using Join to convert the arrays to strings (There's a Split function too):

If Join(arr1) = Join(arr2) Then
. . .
End If


"RB Smissaert" wrote:

Not sure I get the way you make your arrays.
Can't you simply do:

With ws
arr1 = .Range(.Cells(3, 2), .Cells(5, lastrow))
arr2 = .Range(.Cells(3, 1), .Cells(5, lastrow - 1))
End With

As to comparing arrays. I don't think there is any other way than to loop
through
all the array elements, of course getting out the loops if you find a
difference.
The only refinement I can think of is loop in such a way that you are most
likely
to get a non-matching element as early as possible.


RBS


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
if i create 2 arrays from a range, is there a way to compare the entire
array, instead of element by element?


For i = 2 To lastrow
arr1 = ws.Range("c" & i & ":E" & i)
arr2 = ws.Range("c" & i - 1 & ":E" & i - 1)

i want to know when arr1 = arr2.

right now i just use a loop to check the elements and if they all match, i
continue on.
--


Gary