none
Loop in Array- Problem RRS feed

  • Question

  • Sub macro()

    Dim spot As Double
    Dim up As Double
    Dim lattice() As Variant
    ReDim lattice(1 To 4, 1 To 4) As Variant


    spot = Range("spot").Value
    up = Range("up").Value
     Dim i As Integer

    lattice(1, 1) = spot
    For i = 1 To 4
    lattice(1, i + 1) = up * lattice(1, i)
    Next i

    Range("treee") = lattice


    End Sub

    Please identify what is the error in bold line.

     
    Sunday, May 6, 2018 6:07 AM

All replies

  • In last run when i=4 then it will try to assign value to lattice(1,5).

    spot and up must have some number.


    Best Regards, Asadulla Javed


    Sunday, May 6, 2018 7:17 AM
    Answerer