Populating and Comparing Arrays
Hi
You must say what size the array is and what data type. Do you really
want variable declaration outside the sub too? Put the Dim statements
inside the sub if they are only used there.
Option Explicit
Dim Entry1(1 to 2) as Double 'or integer etc
Dim Checker(1 to 2) as Double
Dim Points As Integer
Dim X As Integer
Sub Compare()
For X = 1 To 2
Entry1(X) = Workbooks("Entry1.xls").Sheets("sheet1").Cells(3 + (5 *
X),
4).Value 'This is what the debugger keeps flagging
as wrong
Checker(X) = Sheets("Source").Cells(3 + (5 * X), 4).Value
If Entry1(X) = Checker(X) Then Points = Points + 1
Next X
ThisWorkbook.Sheets("Summary").Range("c6") = Points
End Sub
regards
Paul
On Mar 23, 7:39*pm, Nick wrote:
I want to feed two sets of cells into two arrays and then compare the array
values. *If the values compared within the array match I want to add 1 to a
variable I called "Points". *This is the code I have so far to do this:
Option Explicit
Dim Entry1()
Dim Checker()
Dim Points As Integer
Dim X As Integer
Sub Compare()
For X = 1 To 2
Entry1(X) = Workbooks("Entry1.xls").Sheets("sheet1").Cells(3 + (5 * X), *
4).Value * * * * * * * * * 'This is what the debugger keeps flagging as wrong
Checker(X) = Sheets("Source").Cells(3 + (5 * X), 4).Value
If Entry1(X) = Checker(X) Then Points = Points + 1
Next X
ThisWorkbook.Sheets("Summary").Range("c6") = Points
End Sub
|