Thread: array question
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jerry W. Lewis Jerry W. Lewis is offline
external usenet poster
 
Posts: 837
Default array question

VBA has no concept analogous to the worksheet array formula. However, the
VBA Evaluate() function will have Excel evaluate a string expression as
though it were an array entered formula.

If everything is numeric, you could use
IF Evaluate("MAX(ABS(c" & i & ":E" & i &"-c" & i - 1 & ":E" & i - 1 &
"))") = 0 Then
to test for equality of all corresponding cells.

If there may be non-numeric values, you could construct an Excel expression
that would coerce the array of logical comparisons into numbers and summarize
as a single value for return to VBA, such as
IF Evaluate("MIN(1*(c" & i & ":E" & i &"=c" & i - 1 & ":E" & i - 1 & "))")
= 0 Then
to test for inequality of at least on of the corresponding cells.

Jerry

"Gary Keramidas" wrote:

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