I'm trying to create a little program behind a excel(2003) button. I understood the language to use is Visual Basic and hopefully I'm in the right section of the forum.
I have this piece of code so far :
My problems seems to be in the lines with red where i reefer to a cell using variables for the cell's coordinates. First to compare the value from that cell with something, as an if condition, second time, to assign a certain value from an array to a cell. The error I get is "Application-defined or object-defined error" .
For x = lines_start To lines_limit
For y = coulumns_start To columns_limit
k = 0
For i = 1 To cond_nr
'verifying first possible value
vertically_available = yes 'vertically
For j = lines_start To lines_limit
If Sheet1.Cells(y, j) = possibleValues(i) Then
vertically_available = no
If vertically_available = yes And horizontally_available = yes Then
k = k + 1
finalValues(k) = possibleValues(i)
'randomvalue = CInt(Int((upperbound - lowerbound + 1) * Rnd() + lowerbound))
luck = CInt(Int((k - 1 + 1) * Rnd() + 1))
Sheet1.Cells(x, y) = finalValues(luck)
(obviously all the variables and arrays used are correctly declared but I didn;t post that part of the program too)
Does anyone have any idea how to overcome this ?