Hi,

can anyone please explain me why I get the mentioned error message ?

I got the error message by the following row: "unitprice(j) = Cells(j, 2)"

Thank you


Sub tombok()


Dim unitprice() As Integer
Dim productcode() As String

Dim nrofproducts As Integer
Dim j As Integer


nrofproducts = Range("D1").Value
ReDim productcode(nrofproducts)
ReDim unitprice(nrofproducts)


For j = 1 To nrofproducts

productcode(j) = Cells(j, 1)

unitprice(j) = Cells(j, 2)

Next

Dim n As String

n = InputBox("Please enter the product code")