Re: array question



I'm sure it is slower, but the OP seemed to be interested in simplicity not
speed. What's a few banano-seconds if the project is not compute intensive?

"RB Smissaert" wrote:

Not sure that is any faster and my guess is that it is slower.
VB(A) is slow with string concatenations, plus you may come across
a differing array element early in the loops so exit early.
Only some testing will tell for sure what the fastest method is.

RBS

"Charlie" <Charlie@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:9EA2E411-EAE8-4327-9DAD-1DBF7B4E57EF@xxxxxxxxxxxxxxxx
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
news:e1g0ziMvHHA.736@xxxxxxxxxxxxxxxxxxxxxxx
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







.



Relevant Pages

  • Re: Common Lisp implementations are still multiple times slower than C
    ... ARRAY element type when doing MAKE-ARRAY. ... that a simple-vector can hold every element. ... used "(loop for y fixnum from 0 below height..." ...
    (comp.lang.lisp)
  • Re: Efficient solution needed
    ... > Can any one plzz solve the following problem in an efficient way... ... > Multiplies this number by 2. ... A simple loop, ... get a number for which the array element is already 1. ...
    (comp.programming)
  • Re: how to search d15?
    ... of each array element? ... but I'm too busy to write a test example right now. ... concatenating the results into the label text in a loop. ... But not getting "d15" AT ALL? ...
    (microsoft.public.vb.general.discussion)
  • Re: Removing entry from @rray
    ... Redefining the @array element inside to loop ... WORD must be delimited by word boundaries, ... match is found I would want to terminate the loop so that it doesn't waste time checking all the other array elements for a match. ...
    (comp.lang.perl.misc)

Loading