[vba] x = Range("A2", Range("a2").End(xlDown)).Cells.Count
Dim codes(10)
For i = 1 To x
codes(i) = ActiveCell.Value
[/vba]
Your error likely is that "x" may be larger (ie. more rows) than 10 which is what you dimmed your "x" to. So it errors on "codes(i) = ActiveCell.Value" as you are probably beyond the scope of your array. This won't hurt and it's just a guess. Dave
[vba] x = Range("A2", Range("a2").End(xlDown)).Cells.Count
Dim codes(x)
For i = 0 To (x -1)
codes(i) = ActiveCell.Value
[/vba]
...needs this too..
[vba]
For b = 0 To (x - 1)

[/vba]