У меня есть проблема, которую я просто не могу исправить.Мне нужно выяснить, существует ли продукт, поэтому его не следует обрабатывать дважды (или более).Вот мой код:
Dim table As Variant
finalLig = Cells(Application.Rows.Count, 1).End(xlUp).row
table= Range("C3:D" & finalLig).Value 'two dimensionnal array (nb of products, 2 columns. 2nd column is just here to create a multidimmensionnal array)
For i = LBound(tableau) To UBound(table) 'For all values in the array (barcodes)
If table(i, 2) <> 1 Then
Valeur = table(i, 1) 'Value to check
For J = LBound(tableau) To UBound(tableau) 'Loop in the table
valeurComp = tableau(J, 1)
If Valeur = valeurComp And i <> J Then 'If two lines share the same code, then
table(i, 2) = 1 'remember that this value shouldn't be treated once in the i loop
'my actions here
End If
Next J
End If
Next i
Здесь, когда я отлаживаю, я вижу, что значение (i, 2) никогда не устанавливается на 1, поэтому мои продукты обрабатываются дважды.Я просто не могу понять, почему.
Спасибо за вашу помощь.